diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-02-07 04:29:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-07 13:29:18 +0100 |
commit | 79ec8c257183e01c01811a34e3930de7814756fb (patch) | |
tree | 1377758b7d20d72915fd1e6dab3ec2da17c7fc46 /tests/errmsgs | |
parent | c0a2e2ed92610933983d1edb57d1ad0204189f61 (diff) | |
download | Nim-79ec8c257183e01c01811a34e3930de7814756fb.tar.gz |
fix #13182: `proc fun(a: varargs[Foo, conv])` now can be overloaded (#13345) [backport]
Diffstat (limited to 'tests/errmsgs')
-rw-r--r-- | tests/errmsgs/tsigmatch2.nim | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/errmsgs/tsigmatch2.nim b/tests/errmsgs/tsigmatch2.nim new file mode 100644 index 000000000..c4eb4c197 --- /dev/null +++ b/tests/errmsgs/tsigmatch2.nim @@ -0,0 +1,47 @@ +discard """ + cmd: "nim check --showAllMismatches:on --hints:off $file" + nimout: ''' +tsigmatch2.nim(40, 14) Error: type mismatch: got <float64> +but expected one of: +proc foo(i: Foo): string + first type mismatch at position: 1 + required type for i: Foo + but expression '1.2' is of type: float64 +proc foo(args: varargs[string, myproc]): string + first type mismatch at position: 1 + required type for args: varargs[string] + but expression '1.2' is of type: float64 + +expression: foo(1.2) +tsigmatch2.nim(46, 7) Error: type mismatch: got <int literal(1)> +but expected one of: +proc foo(args: varargs[string, myproc]) + first type mismatch at position: 1 + required type for args: varargs[string] + but expression '1' is of type: int literal(1) + +expression: foo 1 +''' + errormsg: "type mismatch" +""" + + + +# line 30 + +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)"]""" + doAssert not compiles(foo(1.2)) + discard foo(1.2) + +block: + proc myproc[T](x: T): string = + let temp = 12.isNil + proc foo(args: varargs[string, myproc]) = discard + foo 1 +static: echo "done" \ No newline at end of file |