Why are those types still defined? Is this a bug?
import macros
macro nothingShouldHappen(n: stmt): stmt = return newNimNode(nnkDiscardStmt).add(newEmptyNode())
nothingShouldHappen:
type
Persone = tuple[name, age: int]
Eventi = tuple[name: string, description: string, person_set: Persone]
echo 5
var c: Eventi
This is my compiler version: Nim Compiler Version 0.11.2 (2015-05-04) [Linux: amd64]
This should probably become an FAQ. :)
Short answer: the argument still has to be typechecked. This means in particular that all declarations inside have to be processed.
Solution: Use untyped instead of stmt (and stmt is an alias for typed). I.e.:
import macros
macro nothingShouldHappen(n: untyped): stmt = return newNimNode(nnkDiscardStmt).add(newEmptyNode())
nothingShouldHappen:
type
Persone = tuple[name, age: int]
Eventi = tuple[name: string, description: string, person_set: Persone]
echo 5
var c: Eventi
When you compile the above, you'll get the expected error message because Eventi is not declared.