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

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

Closed
tersec opened this issue Sep 22, 2024 · 1 comment · Fixed by #24152

Comments

@tersec
Copy link
Contributor

tersec commented Sep 22, 2024

Description

proc w(T: type): T {.compileTime.} = default(ptr T)[]
template y(v: auto): auto = typeof(v) is int
discard compiles(y(w int))
proc s(): int {.compileTime.} = discard
discard s()

Nim Version

Builds:

Nim Compiler Version 2.0.8 [Linux: amd64]
Compiled at 2024-09-21
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 5935c3bfa9fec6505394867b23510eb5cbab3dbf
active boot switches: -d:release

Does not build:

Nim Compiler Version 2.0.9 [Linux: amd64]
Compiled at 2024-09-22
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 27381cc60213e19aa34664176bd358ca5e45bd5a
active boot switches: -d:release
Nim Compiler Version 2.1.99 [Linux: amd64]
Compiled at 2024-09-22
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 755307be61e4ee7b32c8354b2c303d04bdfc3a3e
active boot switches: -d:release
Nim Compiler Version 2.1.99 [Linux: amd64]
Compiled at 2024-09-22
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: d51d88700b2fb3bd228d5e8f7385e2e4a2e2880c
active boot switches: -d:release

Current Output

/tmp/k.nim(5, 9) Error: request to generate code for .compileTime proc: s

Expected Output

No response

Known Workarounds

No response

Additional Information

No response

@metagn
Copy link
Collaborator

metagn commented Sep 22, 2024

Caused by #22022, must have sucked to reduce lol

@Araq Araq closed this as completed in a177720 Sep 22, 2024
narimiran pushed a commit that referenced this issue 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 a pull request may close this issue.

2 participants