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

.compileTime proc with static argument is not folded #22021

Closed
metagn opened this issue Jun 6, 2023 · 1 comment · Fixed by #22022
Closed

.compileTime proc with static argument is not folded #22021

metagn opened this issue Jun 6, 2023 · 1 comment · Fixed by #22022

Comments

@metagn
Copy link
Collaborator

metagn commented Jun 6, 2023

Description

block:
  proc foo(x: int): int {.compileTime.} = x + 1
  echo foo(123) # works
block:
  proc foo(x: static int): int {.compileTime.} = x + 1
  echo foo(123) # fails

Nim Version

b97d603

Current Output

(6, 8) Error: request to generate code for .compileTime proc: foo

Expected Output

124

Possible Solution

No response

Additional Information

No response

@metagn
Copy link
Collaborator Author

metagn commented Jun 6, 2023

Apparently #10753

metagn added a commit to metagn/Nim that referenced this issue Jun 6, 2023
metagn added a commit to metagn/Nim that referenced this issue Jun 13, 2023
metagn added a commit to metagn/Nim that referenced this issue Aug 16, 2024
@Araq Araq closed this as completed in f7c11a8 Aug 17, 2024
narimiran pushed a commit that referenced this issue Sep 13, 2024
fixes #10753, fixes #22021, refs #19365 (was fixed by #22029, but more
faithful test added)

For whatever reason `compileTime` proc calls did not fold if the proc
was generic ([since this folding was
introduced](c25ffbf#diff-539da3a63df08fa987f1b0c67d26cdc690753843d110b6bf0805a685eeaffd40)).
I'm guessing the intention was for *unresolved* generic procs to not
fold, which is now the logic.

Non-magic `compileTime` procs also now don't fold at compile time in
`typeof` contexts to avoid possible runtime errors (only the important)
and prevent double/needless evaluation.

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

1 participant