Nim
Nim copied to clipboard
captured NimNode becomes NilLit
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: b47747d31844c6bd9af4322efe55e24fefea544c 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
Related #3855, same issue #18352