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).
template foo*(a: string, body: untyped) : untyped =
block:
var fooz {.inject.} = "foo1"
echo a
body
template foo*(body: untyped) : untyped =
block:
var fooz {.inject.} = "foo2"
body
foo("aaa"):
echo "do stuff"
echo fooz
foo:
echo "do stuff2"
echo fooz # Error undeclared identifier 'fooz'
Current Output
Error: undeclared identifier: 'fooz'
Expected Output
Should compile and echo normally. Renaming the injected variable to different identifier doesn't change anything.
Changing template name to 2 different identifier makes it work.
Tested on both 1.6.4 and latest devel
$ nim -v
Nim Compiler Version 1.6.4 [Linux: amd64]
Compiled at 2022-02-09
Copyright (c) 2006-2021 by Andreas Rumpf
git hash: 7994556f3804c217035c44b453a3feec64405758
active boot switches: -d:release
$ nim -v
Nim Compiler Version 1.7.1 [Linux: amd64]
Compiled at 2022-02-19
Copyright (c) 2006-2022 by Andreas Rumpf
git hash: 516db3bac389ea554166ee1a6671b5005159a30a
active boot switches: -d:release
Example
Current Output
Error: undeclared identifier: 'fooz'
Expected Output
Should compile and echo normally. Renaming the injected variable to different identifier doesn't change anything. Changing template name to 2 different identifier makes it work.
Tested on both 1.6.4 and latest devel