Closed metagn closed 1 month ago
Thanks for your hard work on this PR! The lines below are statistics of the Nim compiler built from ca5df9ab25f1444025f9b8928cf21893a160489b
Hint: mm: orc; opt: speed; options: -d:release 175305 lines; 8.622s; 654.898MiB peakmem
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 ofinject
orgensym
). To fix this, we wrap the unrolled iterations in anif true: body
node, which both opens a new scope and doesn't interfere withbreak
.