diff options
author | Zahary Karadjov <zahary@gmail.com> | 2017-06-19 22:07:54 +0300 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-06-20 11:29:42 +0200 |
commit | a6006e56a7eef8e4d678c8369cee6ba66094dd67 (patch) | |
tree | 80e556881f6ef6b473fca35b0d302884275d8452 /tests | |
parent | 16eb4b1fee14e41807ff5c368ea848b71f258182 (diff) | |
download | Nim-a6006e56a7eef8e4d678c8369cee6ba66094dd67.tar.gz |
Fix #4737
Diffstat (limited to 'tests')
-rw-r--r-- | tests/errmsgs/tconceptconstraint.nim | 21 | ||||
-rw-r--r-- | tests/errmsgs/tgenericconstraint.nim | 15 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/errmsgs/tconceptconstraint.nim b/tests/errmsgs/tconceptconstraint.nim new file mode 100644 index 000000000..c1f0b94eb --- /dev/null +++ b/tests/errmsgs/tconceptconstraint.nim @@ -0,0 +1,21 @@ +discard """ + errormsg: "cannot instantiate B" + line: 20 + nimout: ''' +got: (type string) +but expected: (T: A) +''' +""" + +type + A = concept c + advance(c) + + B[T: A] = object + child: ref B[T] + +proc advance(x: int): int = x + 1 + +var a: B[int] +var b: B[string] + diff --git a/tests/errmsgs/tgenericconstraint.nim b/tests/errmsgs/tgenericconstraint.nim new file mode 100644 index 000000000..9129d257b --- /dev/null +++ b/tests/errmsgs/tgenericconstraint.nim @@ -0,0 +1,15 @@ +discard """ + errormsg: "cannot instantiate B" + line: 14 + nimout: ''' +got: (type int) +but expected: (T: string or float) +''' +""" + +type + B[T: string|float] = object + child: ref B[T] + +var b: B[int] + |