type trais used to work only on user-defined types. see #202

This commit is contained in:
Zahary Karadjov 2012-09-13 00:33:01 +03:00
commit 9e4254e4de
2 changed files with 16 additions and 3 deletions

View file

@ -1,10 +1,11 @@
discard """
msg: "int\nstring\nTBar[int]"
output: "int\nstring\nTBar[int]"
output: "int\nstring\nTBar[int]\nint\nrange 0..2"
"""
import typetraits
# simple case of type trait usage inside/outside of static blocks
proc foo(x) =
static:
var t = type(x)
@ -22,3 +23,16 @@ foo 10
foo "test"
foo bar
# generic params on user types work too
proc foo2[T](x: TBar[T]) =
echo T.name
foo2 bar
# less usual generic params on built-in types
var arr: array[0..2, int] = [1, 2, 3]
proc foo3[R, T](x: array[R, T]) =
echo name(R)
foo3 arr