From a6006e56a7eef8e4d678c8369cee6ba66094dd67 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 19 Jun 2017 22:07:54 +0300 Subject: Fix #4737 --- tests/errmsgs/tconceptconstraint.nim | 21 +++++++++++++++++++++ tests/errmsgs/tgenericconstraint.nim | 15 +++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/errmsgs/tconceptconstraint.nim create mode 100644 tests/errmsgs/tgenericconstraint.nim (limited to 'tests') 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] + -- cgit 1.4.1-2-gfad0