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

fix inTypeofContext leaking after compiles raises exception [backport:2.0] #24152

Merged
merged 1 commit into from
Sep 22, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Sep 22, 2024

fixes #24150, refs #22022

An exception is raised in the semExprWithType call, which means dec c.inTypeofContext is never called, but compiles allows compilation to continue. This means c.inTypeofContext is left perpetually nonzero, which prevents compileTime evaluation for the rest of the program.

To fix this, defer: is used for the dec c.inTypeofContext call, as is done for instCounter in other parts of the compiler.

@Araq Araq merged commit a177720 into nim-lang:devel Sep 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 a177720

Hint: mm: orc; opt: speed; options: -d:release
174460 lines; 8.111s; 653.98MiB peakmem

narimiran pushed a commit that referenced this pull request Sep 28, 2024
…port:2.0] (#24152)

fixes #24150, refs #22022

An exception is raised in the `semExprWithType` call, which means `dec
c.inTypeofContext` is never called, but `compiles` allows compilation to
continue. This means `c.inTypeofContext` is left perpetually nonzero,
which prevents `compileTime` evaluation for the rest of the program.

To fix this, `defer:` is used for the `dec c.inTypeofContext` call, as
is done for
[`instCounter`](https://github.com/nim-lang/Nim/blob/d51d88700b2fb3bd228d5e8f7385e2e4a2e2880c/compiler/seminst.nim#L374)
in other parts of the compiler.

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

Regression from 2.0.8 to version-2-0/version-2-2/devel with compileTime procs and compiles(...)
2 participants