From 83e715c5b6b2501c02459398a2f394c457758a55 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 5 Mar 2020 16:02:34 +0100 Subject: fixes #5170 (#13589) * fixes #5170 * make tests green --- tests/errmsgs/tsigmatch.nim | 6 +++--- tests/errmsgs/tsigmatch2.nim | 4 ++-- tests/types/tissues_types.nim | 30 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/errmsgs/tsigmatch.nim b/tests/errmsgs/tsigmatch.nim index 21e2c217d..6b85d1408 100644 --- a/tests/errmsgs/tsigmatch.nim +++ b/tests/errmsgs/tsigmatch.nim @@ -98,13 +98,13 @@ expression: fun1(default(Mystring), "asdf") ## line 100 -block: +when true: # bug #11061 Type mismatch error "first type mismatch at" points to wrong argument/position # Note: the error msg now gives correct position for mismatched argument type A = object of RootObj B = object of A - +block: proc f(b: B) = discard proc f(a: A) = discard @@ -163,7 +163,7 @@ block: var foo = "" f(foo, a0 = 12) -block: +when true: type Mystring = string type MyInt = int proc fun1(a1: MyInt, a2: Mystring) = discard diff --git a/tests/errmsgs/tsigmatch2.nim b/tests/errmsgs/tsigmatch2.nim index c4eb4c197..4e95d3e1b 100644 --- a/tests/errmsgs/tsigmatch2.nim +++ b/tests/errmsgs/tsigmatch2.nim @@ -28,11 +28,11 @@ expression: foo 1 # line 30 - +type Foo = object block: # issue #13182 proc myproc(a: int): string = $("myproc", a) proc foo(args: varargs[string, myproc]): string = $args - type Foo = object + proc foo(i: Foo): string = "in foo(i)" static: doAssert foo(Foo()) == "in foo(i)" static: doAssert foo(1) == """["(\"myproc\", 1)"]""" diff --git a/tests/types/tissues_types.nim b/tests/types/tissues_types.nim index e5039fa61..7ed0547bf 100644 --- a/tests/types/tissues_types.nim +++ b/tests/types/tissues_types.nim @@ -8,6 +8,8 @@ ptr Foo (member: 123.456) (member: "hello world", x: ...) (member: 123.456, x: ...) +0 +false ''' joinable: false """ @@ -78,3 +80,31 @@ block t7905: foobarRec("hello world") foobarRec(123.456'f64) + +# bug #5170 + +when true: + type Foo = object + bar: bool + + type Bar = object + sameBody: string + + var b0: Bar + b0.sameBody = "abc" + +block: + type Foo = object + baz: int + + type Bar = object + sameBody: string + + var b1: Bar + b1.sameBody = "def" + + var f2: Foo + echo f2.baz + +var f1: Foo +echo f1.bar -- cgit 1.4.1-2-gfad0