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).
https://nim-lang.org
Other
16.47k stars 1.47k forks source link

when nimvm visible in runtime code causing misexecution due to matching preference rules #23688

Open arnetheduck opened 3 months ago

arnetheduck commented 3 months ago

Description

when nimvm:
  proc mytest(a: int) =
    echo a
else:
  template mytest(a: untyped) =
    echo a + 42

proc xxx() =
  mytest(100)
xxx()

Nim Version

1.6, 2.0

Current Output

100

Expected Output

142

Possible Solution

No response

Additional Information

No response

arnetheduck commented 3 months ago

a variation on #23687

Araq commented 3 months ago

Well the VM evals the toplevel statement and thus the "proc" branch is the active one. It produces the output that I would have predicted.