summary refs log tree commit diff stats
path: root/tests/errmsgs/tsigmatch.nim
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2019-07-06 22:13:01 -0700
committerTimothee Cour <timothee.cour2@gmail.com>2019-07-08 15:24:20 -0700
commit5ddea6a98fd215276a895d6ac4168f5998813f45 (patch)
treeb9b156fa5d543667c0e1408f3644f892ea07417f /tests/errmsgs/tsigmatch.nim
parent5fce81edfd7690582ac4c5fec37cd418061f6334 (diff)
downloadNim-5ddea6a98fd215276a895d6ac4168f5998813f45.tar.gz
add tests for #8305 #7808 #10285 #11061 + other bugs
Diffstat (limited to 'tests/errmsgs/tsigmatch.nim')
-rw-r--r--tests/errmsgs/tsigmatch.nim116
1 files changed, 98 insertions, 18 deletions
diff --git a/tests/errmsgs/tsigmatch.nim b/tests/errmsgs/tsigmatch.nim
index c84357412..1993a2724 100644
--- a/tests/errmsgs/tsigmatch.nim
+++ b/tests/errmsgs/tsigmatch.nim
@@ -1,19 +1,18 @@
 discard """
   cmd: "nim check --showAllMismatches:on --hints:off $file"
   nimout: '''
-tsigmatch.nim(76, 7) Error: type mismatch: got <Mystring, string>
+tsigmatch.nim(161, 4) Error: type mismatch: got <A, string>
 but expected one of:
-proc fun1(a1: MyInt; a2: Mystring)
-  first type mismatch at position: 1
-  required type for a1: MyInt
-  but expression 'default(Mystring)' is of type: Mystring
-proc fun1(a1: float; a2: Mystring)
+proc f(b: B)
   first type mismatch at position: 1
-  required type for a1: float
-  but expression 'default(Mystring)' is of type: Mystring
+  required type for b: B
+  but expression 'A()' is of type: A
+proc f(a: A)
+  first type mismatch at position: 2
+  extra argument given
 
-expression: fun1(default(Mystring), "asdf")
-tsigmatch.nim(82, 6) Error: type mismatch: got <tuple of (string, proc (){.gcsafe, locks: 0.})>
+expression: f(A(), "extra")
+tsigmatch.nim(175, 6) Error: type mismatch: got <tuple of (string, proc (){.gcsafe, locks: 0.})>
 but expected one of:
 proc foo(x: (string, proc ()))
   first type mismatch at position: 1
@@ -21,17 +20,69 @@ proc foo(x: (string, proc ()))
   but expression '("foobar", proc () = echo(["Hello!"]))' is of type: tuple of (string, proc (){.gcsafe, locks: 0.})
 
 expression: foo(("foobar", proc () = echo(["Hello!"])))
-tsigmatch.nim(95, 4) Error: type mismatch: got <A, string>
+tsigmatch.nim(182, 11) Error: type mismatch: got <proc (s: string): string{.noSideEffect, gcsafe, locks: 0.}>
 but expected one of:
-proc f(b: B)
+proc foo[T, S](op: proc (x: T): S {.cdecl.}): auto
   first type mismatch at position: 1
-  required type for b: B
-  but expression 'A()' is of type: A
-proc f(a: A)
+  required type for op: proc (x: T): S{.cdecl.}
+  but expression 'fun' is of type: proc (s: string): string{.noSideEffect, gcsafe, locks: 0.}
+proc foo[T, S](op: proc (x: T): S {.safecall.}): auto
+  first type mismatch at position: 1
+  required type for op: proc (x: T): S{.safecall.}
+  but expression 'fun' is of type: proc (s: string): string{.noSideEffect, gcsafe, locks: 0.}
+
+expression: foo(fun)
+tsigmatch.nim(193, 13) Error: type mismatch: got <array[0..0, proc (x: int){.gcsafe, locks: 0.}]>
+but expected one of:
+proc takesFuncs(fs: openArray[proc (x: int) {.gcsafe, locks: 0.}])
+  first type mismatch at position: 1
+  required type for fs: openarray[proc (x: int){.closure, gcsafe, locks: 0.}]
+  but expression '[proc (x: int) {.gcsafe, locks: 0.} = echo [x]]' is of type: array[0..0, proc (x: int){.gcsafe, locks: 0.}]
+
+expression: takesFuncs([proc (x: int) {.gcsafe, locks: 0.} = echo [x]])
+tsigmatch.nim(199, 4) Error: type mismatch: got <int literal(10), a0: int literal(5), string>
+but expected one of:
+proc f(a0: uint8; b: string)
   first type mismatch at position: 2
-  extra argument given
+  named param already provided: a0
 
-expression: f(A(), "extra")
+expression: f(10, a0 = 5, "")
+tsigmatch.nim(206, 4) Error: type mismatch: got <string, string, string, string, string, float64, string>
+but expected one of:
+proc f(a1: int)
+  first type mismatch at position: 1
+  required type for a1: int
+  but expression '"asdf"' is of type: string
+proc f(a1: string; a2: varargs[string]; a3: float; a4: var string)
+  first type mismatch at position: 7
+  required type for a4: var string
+  but expression '"bad"' is immutable, not 'var'
+
+expression: f("asdf", "1", "2", "3", "4", 2.3, "bad")
+tsigmatch.nim(214, 4) Error: type mismatch: got <string, a0: int literal(12)>
+but expected one of:
+proc f(x: string; a0: var int)
+  first type mismatch at position: 2
+  required type for a0: var int
+  but expression 'a0 = 12' is immutable, not 'var'
+proc f(x: string; a0: string)
+  first type mismatch at position: 2
+  required type for a0: string
+  but expression 'a0 = 12' is of type: int literal(12)
+
+expression: f(foo, a0 = 12)
+tsigmatch.nim(221, 7) Error: type mismatch: got <Mystring, string>
+but expected one of:
+proc fun1(a1: MyInt; a2: Mystring)
+  first type mismatch at position: 1
+  required type for a1: MyInt
+  but expression 'default(Mystring)' is of type: Mystring
+proc fun1(a1: float; a2: Mystring)
+  first type mismatch at position: 1
+  required type for a1: float
+  but expression 'default(Mystring)' is of type: Mystring
+
+expression: fun1(default(Mystring), "asdf")
 '''
   errormsg: "type mismatch"
 """
@@ -67,7 +118,36 @@ expression: f(A(), "extra")
 
 
 
-## line 70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## line 150
 block:
   # 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