nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).

Home Page:https://nim-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

captured NimNode becomes NilLit

levovix0 opened this issue · 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: 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

Related #3855, same issue #18352