diff options
author | Zahary Karadjov <zahary@gmail.com> | 2015-01-05 03:57:09 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2015-01-05 03:57:09 +0200 |
commit | f2fdac531dc73695018ceb38d4c9f017f8c34b2a (patch) | |
tree | d26f0c7041ea12c0313758b5f69387495391c43f /tests | |
parent | f3c55704a0832828317e0c357ac24c003d3a45ea (diff) | |
download | Nim-f2fdac531dc73695018ceb38d4c9f017f8c34b2a.tar.gz |
test cases for generic macros
Diffstat (limited to 'tests')
-rw-r--r-- | tests/static/tstaticparammacro.nim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/static/tstaticparammacro.nim b/tests/static/tstaticparammacro.nim index 7fb9e2014..ebd6caa47 100644 --- a/tests/static/tstaticparammacro.nim +++ b/tests/static/tstaticparammacro.nim @@ -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) + |