experimental support for querying the type of expressions within macros

normalised the line endings of macros.nim (minor edits otherwise)
This commit is contained in:
Zahary Karadjov 2012-10-03 01:50:26 +03:00
commit 2e5265bef5
5 changed files with 369 additions and 344 deletions

View file

@ -0,0 +1,12 @@
import macros, typetraits
macro checkType(ex, expected: expr): stmt {.immediate.} =
var t = ex.typ
assert t.name == expected.strVal
proc voidProc = echo "hello"
proc intProc(a, b): int = 10
checkType(voidProc(), "void")
checkType(intProc(10, 20.0), "int")
checkType(noproc(10, 20.0), "Error Type")