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

wrap fields iterations in if true scope [backport] #24343

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Oct 22, 2024

fixes #24338

When unrolling each iteration of a fields iterator, the compiler only opens a new scope for semchecking, but doesn't generate a node that signals to the codegen that a new scope should be created. This causes issues for reused template instantiations that reuse variable symbols between each iteration, which causes the codegen to generate multiple declarations for them in the same scope (regardless of inject or gensym). To fix this, we wrap the unrolled iterations in an if true: body node, which both opens a new scope and doesn't interfere with break.

@Araq Araq merged commit ca5df9a into nim-lang:devel Oct 22, 2024
19 checks passed
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from ca5df9a

Hint: mm: orc; opt: speed; options: -d:release
175305 lines; 8.622s; 654.898MiB peakmem

narimiran pushed a commit that referenced this pull request Oct 23, 2024
fixes #24338

When unrolling each iteration of a `fields` iterator, the compiler only
opens a new scope for semchecking, but doesn't generate a node that
signals to the codegen that a new scope should be created. This causes
issues for reused template instantiations that reuse variable symbols
between each iteration, which causes the codegen to generate multiple
declarations for them in the same scope (regardless of `inject` or
`gensym`). To fix this, we wrap the unrolled iterations in an `if true:
body` node, which both opens a new scope and doesn't interfere with
`break`.

(cherry picked from commit ca5df9a)
narimiran pushed a commit that referenced this pull request Oct 23, 2024
fixes #24338

When unrolling each iteration of a `fields` iterator, the compiler only
opens a new scope for semchecking, but doesn't generate a node that
signals to the codegen that a new scope should be created. This causes
issues for reused template instantiations that reuse variable symbols
between each iteration, which causes the codegen to generate multiple
declarations for them in the same scope (regardless of `inject` or
`gensym`). To fix this, we wrap the unrolled iterations in an `if true:
body` node, which both opens a new scope and doesn't interfere with
`break`.

(cherry picked from commit ca5df9a)
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.

error: redeclaration of ‘qX60gensym0_’ with no linkage with nested templates
2 participants