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

reset inTypeofContext in generic instantiations #24229

Merged
merged 1 commit into from
Oct 6, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Oct 3, 2024

fixes #24228, refs #22022

As described in #24228 (comment), instantiating generic routines inside typeof causes all code inside to be treated as being in a typeof context, and thus preventing compile time proc folding, causing issues when code is generated for the instantiated routine. Now, instantiated generic procs are treated as never being inside a typeof context.

This is probably an arbitrary special case and more issues with the typeof behavior from #22022 are likely. Ideally this behavior would be removed but it's necessary to accomodate the current proc declval in the package stew, at least without changes to compileTime that would either break other code (making it not eagerly fold by default) or still require a change in stew (adding an option to disable the eager folding).

Alternatively we could also make the eager folding opt-in only for generic compileTime procs so that #22022 breaks nothing whatsoever, but a universal solution would be better. Edit: Done in #24230 via experimental switch

@metagn metagn changed the title reset inTypeofContext in generic instantiations reset inTypeofContext in generic instantiations [backport:2.0] Oct 5, 2024
@metagn metagn changed the title reset inTypeofContext in generic instantiations [backport:2.0] reset inTypeofContext in generic instantiations Oct 5, 2024
@Araq Araq merged commit ea9811a into nim-lang:devel Oct 6, 2024
19 checks passed
Copy link
Contributor

github-actions bot commented Oct 6, 2024

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

Hint: mm: orc; opt: speed; options: -d:release
174979 lines; 8.193s; 653.488MiB peakmem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants