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

captured NimNode becomes NilLit #23567

Open
levovix0 opened this issue May 3, 2024 · 1 comment
Open

captured NimNode becomes NilLit #23567

levovix0 opened this issue May 3, 2024 · 1 comment
Labels

Comments

@levovix0
Copy link

levovix0 commented May 3, 2024

Description

macro foo(arg: int): int =
  proc impl(): NimNode = arg
  impl()

echo foo(11)

invalidly captures arg into impl

Nim Version

Nim Compiler Version 2.0.4 [Linux: amd64]
Compiled at 2024-03-28
Copyright (c) 2006-2023 by Andreas Rumpf

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

Current Output

a.nim(5, 9) template/generic instantiation of `foo` from here
a.nim(3, 3) Error: type mismatch: got 'NimNode' for 'nil' but expected 'int'

Expected Output

11

Possible Solution

No response

Additional Information

after calling impl(), both impl().treeRepr and arg.treeRepr is NilLit

@metagn
Copy link
Collaborator

metagn commented May 3, 2024

Related #3855, same issue #18352

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

No branches or pull requests

3 participants