Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #5034 illformed AST from getImpl with proc returning value #17976

Merged
merged 2 commits into from
May 31, 2021

Conversation

DylanModesitt
Copy link
Contributor

@DylanModesitt DylanModesitt commented May 9, 2021

This is an attempt at fixing #5034, whereby macros that attempt to re-define a proc run into a variety of issues relating to the ownership of the result symbol. For example:

  • addResult, on the 'second pass' would fail because n[resultPos].sym.owner != getCurrOwner(c) which gives "incorrect result proc symbol"
  • result = ... gets re-written to result = result = ... because semReturn in semexprs does transformations twice due to c.p.resultSym != n[0][0].sym in the case of returning nodes sourced from getImpl(Transformed)?

As a fix, ownership mismatch is responded to by re-writing result nodes equal to n[resultPos].sym. As a less-preferred alternative to this PR, the error message for attempting to do this kind of redefinition could be improved to be discouraged.

@timotheecour timotheecour changed the title Fixes 5034 Fixes #5034 illformed AST from getImpl with proc returning value May 9, 2021
@timotheecour
Copy link
Member

This is an attempt at fixing #5034,

if it fixes it, write fixes #5034 in top PR message so that the issue will auto-close and this PR gets cross referenced from the issue

compiler/semstmts.nim Outdated Show resolved Hide resolved
@Araq Araq merged commit 06d50bf into nim-lang:devel May 31, 2021
PMunch pushed a commit to PMunch/Nim that referenced this pull request Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants