test cases for generic macros

This commit is contained in:
Zahary Karadjov
2015-01-05 03:57:09 +02:00
parent f3c55704a0
commit f2fdac531d

View File

@@ -10,6 +10,9 @@ AST a
AST b
(e: [55, 66], f: [77, 88])
55
10
20Test
20
'''
"""
@@ -50,3 +53,22 @@ macro mB(data: static[Tb]): stmt =
mA(a)
mB(b)
type
Foo[N: static[int], Z: static[string]] = object
macro staticIntMacro(f: static[int]): stmt = echo f
staticIntMacro 10
var
x: Foo[20, "Test"]
macro genericMacro[N; Z: static[string]](f: Foo[N, Z], ll = 3, zz = 12): stmt =
echo N, Z
genericMacro x
template genericTemplate[N, Z](f: Foo[N, Z], ll = 3, zz = 12): int = N
static:
echo genericTemplate(x) # Error: internal error: (filename: compiler/evaltempl.nim, line: 39)