summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2018-06-13 01:35:46 +0300
committerZahary Karadjov <zahary@gmail.com>2018-06-16 16:46:32 +0300
commit16b594b5324039ac85f4336c124b16ffc368854f (patch)
tree5a307259bcd3730782fe73bde83f9dbc99385871 /tests
parent5bcf8bcb598d2ca0162f50d2b7250a847026b2c9 (diff)
downloadNim-16b594b5324039ac85f4336c124b16ffc368854f.tar.gz
Support default type parameters
progress on #7516
Diffstat (limited to 'tests')
-rw-r--r--tests/metatype/ttypedesc2.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/metatype/ttypedesc2.nim b/tests/metatype/ttypedesc2.nim
index 4b6cfe6bc..94a7367e7 100644
--- a/tests/metatype/ttypedesc2.nim
+++ b/tests/metatype/ttypedesc2.nim
@@ -34,3 +34,17 @@ when true:
 type Point[T] = tuple[x, y: T]
 proc origin(T: typedesc): Point[T] = discard
 discard origin(int)
+
+# https://github.com/nim-lang/Nim/issues/7516
+import typetraits
+
+proc hasDefault1(T: type = int): auto = return T.name
+doAssert hasDefault1(int) == "int"
+doAssert hasDefault1(string) == "string"
+doAssert hasDefault1() == "int"
+
+proc hasDefault2(T = string): auto = return T.name
+doAssert hasDefault2(int) == "int"
+doAssert hasDefault2(string) == "string"
+doAssert hasDefault2() == "string"
+