diff options
Diffstat (limited to 'tests/template')
-rw-r--r-- | tests/template/tgensymregression.nim | 26 | ||||
-rw-r--r-- | tests/template/tmixin_in_proc.nim | 22 |
2 files changed, 47 insertions, 1 deletions
diff --git a/tests/template/tgensymregression.nim b/tests/template/tgensymregression.nim index e758e0d9a..0fadbde41 100644 --- a/tests/template/tgensymregression.nim +++ b/tests/template/tgensymregression.nim @@ -3,7 +3,8 @@ discard """ [0.0, 0.0, 0.0, 0.0] -5050''' +5050 +123''' """ template mathPerComponent(op: untyped): untyped = @@ -47,3 +48,26 @@ proc main2() = echo s main2() + +# bug #5467 +import macros + +converter int2string(x: int): string = $x + +template wrap(body: typed): untyped = + body + +macro makeProc(): typed = + # Make a template tree + result = (quote do: + proc someProc* = + wrap do: + let x = 123 + # Implicit conversion here + let s: string = x + echo s + ) + +makeProc() + +someProc() diff --git a/tests/template/tmixin_in_proc.nim b/tests/template/tmixin_in_proc.nim new file mode 100644 index 000000000..fede9290b --- /dev/null +++ b/tests/template/tmixin_in_proc.nim @@ -0,0 +1,22 @@ +discard """ + output: '''monkey''' +""" +# bug #5478 +template creature*(name: untyped) = + type + name*[T] = object + color: T + + proc `init name`*[T](c: T): name[T] = + mixin transform + transform() + +creature(Lion) + +type Monkey* = object +proc transform*() = + echo "monkey" + +var + m: Monkey + y = initLion(m) #this one failed to compile |