Nim icon indicating copy to clipboard operation
Nim copied to clipboard

captured NimNode becomes NilLit

Open levovix0 opened this issue 1 year ago • 1 comments

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

levovix0 avatar May 03 '24 19:05 levovix0

Related #3855, same issue #18352

metagn avatar May 03 '24 21:05 metagn