better error messages: use <T1, T2> instead of (T1, T2) in order to prevent confusions with tuple types
This commit is contained in:
parent
51d81c4e23
commit
ef6eda4cb4
25 changed files with 62 additions and 62 deletions
|
|
@ -272,7 +272,7 @@ const
|
||||||
errXStackEscape: "address of '$1' may not escape its stack frame",
|
errXStackEscape: "address of '$1' may not escape its stack frame",
|
||||||
errVarForOutParamNeededX: "for a \'var\' type a variable needs to be passed; but '$1' is immutable",
|
errVarForOutParamNeededX: "for a \'var\' type a variable needs to be passed; but '$1' is immutable",
|
||||||
errPureTypeMismatch: "type mismatch",
|
errPureTypeMismatch: "type mismatch",
|
||||||
errTypeMismatch: "type mismatch: got (",
|
errTypeMismatch: "type mismatch: got <",
|
||||||
errButExpected: "but expected one of: ",
|
errButExpected: "but expected one of: ",
|
||||||
errButExpectedX: "but expected \'$1\'",
|
errButExpectedX: "but expected \'$1\'",
|
||||||
errAmbiguousCallXYZ: "ambiguous call; both $1 and $2 match for: $3",
|
errAmbiguousCallXYZ: "ambiguous call; both $1 and $2 match for: $3",
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ proc notFoundError*(c: PContext, n: PNode, errors: CandidateErrors) =
|
||||||
let (prefer, candidates) = presentFailedCandidates(c, n, errors)
|
let (prefer, candidates) = presentFailedCandidates(c, n, errors)
|
||||||
var result = msgKindToString(errTypeMismatch)
|
var result = msgKindToString(errTypeMismatch)
|
||||||
add(result, describeArgs(c, n, 1, prefer))
|
add(result, describeArgs(c, n, 1, prefer))
|
||||||
add(result, ')')
|
add(result, '>')
|
||||||
if candidates != "":
|
if candidates != "":
|
||||||
add(result, "\n" & msgKindToString(errButExpected) & "\n" & candidates)
|
add(result, "\n" & msgKindToString(errButExpected) & "\n" & candidates)
|
||||||
localError(n.info, errGenerated, result & "\nexpression: " & $n)
|
localError(n.info, errGenerated, result & "\nexpression: " & $n)
|
||||||
|
|
|
||||||
|
|
@ -735,7 +735,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
hasErrorType = true
|
hasErrorType = true
|
||||||
break
|
break
|
||||||
if not hasErrorType:
|
if not hasErrorType:
|
||||||
add(msg, ")\n" & msgKindToString(errButExpected) & "\n" &
|
add(msg, ">\n" & msgKindToString(errButExpected) & "\n" &
|
||||||
typeToString(n.sons[0].typ))
|
typeToString(n.sons[0].typ))
|
||||||
localError(n.info, errGenerated, msg)
|
localError(n.info, errGenerated, msg)
|
||||||
return errorNode(c, n)
|
return errorNode(c, n)
|
||||||
|
|
|
||||||
|
|
@ -1149,8 +1149,8 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
|
||||||
|
|
||||||
if m.state != csMatch:
|
if m.state != csMatch:
|
||||||
let err = "cannot instantiate " & typeToString(t) & "\n" &
|
let err = "cannot instantiate " & typeToString(t) & "\n" &
|
||||||
"got: (" & describeArgs(c, n) & ")\n" &
|
"got: <" & describeArgs(c, n) & ">\n" &
|
||||||
"but expected: (" & describeArgs(c, t.n, 0) & ")"
|
"but expected: <" & describeArgs(c, t.n, 0) & ">"
|
||||||
localError(n.info, errGenerated, err)
|
localError(n.info, errGenerated, err)
|
||||||
return newOrPrevType(tyError, prev, c)
|
return newOrPrevType(tyError, prev, c)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1620,7 +1620,7 @@ proc typeMismatch*(info: TLineInfo, formal, actual: PType) =
|
||||||
let desc = typeToString(formal, preferDesc)
|
let desc = typeToString(formal, preferDesc)
|
||||||
let x = if named == desc: named else: named & " = " & desc
|
let x = if named == desc: named else: named & " = " & desc
|
||||||
var msg = msgKindToString(errTypeMismatch) &
|
var msg = msgKindToString(errTypeMismatch) &
|
||||||
typeToString(actual) & ") " &
|
typeToString(actual) & "> " &
|
||||||
msgKindToString(errButExpectedX) % [x]
|
msgKindToString(errButExpectedX) % [x]
|
||||||
|
|
||||||
if formal.kind == tyProc and actual.kind == tyProc:
|
if formal.kind == tyProc and actual.kind == tyProc:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got (array[0..2, float], array[0..1, float])"
|
errormsg: "type mismatch: got <array[0..2, float], array[0..1, float]>"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc `+`*[R, T] (v1, v2: array[R, T]): array[R, T] =
|
proc `+`*[R, T] (v1, v2: array[R, T]): array[R, T] =
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got (Bar[system.int])"
|
errormsg: "type mismatch: got <Bar[system.int]>"
|
||||||
nimout: '''
|
nimout: '''
|
||||||
t3330.nim(63, 4) Error: type mismatch: got (Bar[system.int])
|
t3330.nim(63, 4) Error: type mismatch: got <Bar[system.int]>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc test(foo: Foo[int])
|
proc test(foo: Foo[int])
|
||||||
t3330.nim(48, 8) Hint: Non-matching candidates for add(k, string, T)
|
t3330.nim(48, 8) Hint: Non-matching candidates for add(k, string, T)
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,14 @@ texplain.nim(70, 6) ExplainedConcept: undeclared field: '.'
|
||||||
texplain.nim(70, 6) ExplainedConcept: expression '.' cannot be called
|
texplain.nim(70, 6) ExplainedConcept: expression '.' cannot be called
|
||||||
texplain.nim(69, 5) ExplainedConcept: concept predicate failed
|
texplain.nim(69, 5) ExplainedConcept: concept predicate failed
|
||||||
|
|
||||||
texplain.nim(113, 20) Error: type mismatch: got (NonMatchingType)
|
texplain.nim(113, 20) Error: type mismatch: got <NonMatchingType>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc e(o: ExplainedConcept): int
|
proc e(o: ExplainedConcept): int
|
||||||
texplain.nim(69, 5) ExplainedConcept: concept predicate failed
|
texplain.nim(69, 5) ExplainedConcept: concept predicate failed
|
||||||
proc e(i: int): int
|
proc e(i: int): int
|
||||||
|
|
||||||
expression: e(n)
|
expression: e(n)
|
||||||
texplain.nim(114, 20) Error: type mismatch: got (NonMatchingType)
|
texplain.nim(114, 20) Error: type mismatch: got <NonMatchingType>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc r(o: RegularConcept): int
|
proc r(o: RegularConcept): int
|
||||||
texplain.nim(73, 5) RegularConcept: concept predicate failed
|
texplain.nim(73, 5) RegularConcept: concept predicate failed
|
||||||
|
|
@ -45,7 +45,7 @@ texplain.nim(115, 20) Hint: Non-matching candidates for r(y)
|
||||||
proc r[T](a: SomeNumber; b: T; c: auto)
|
proc r[T](a: SomeNumber; b: T; c: auto)
|
||||||
proc r(i: string): int
|
proc r(i: string): int
|
||||||
|
|
||||||
texplain.nim(123, 2) Error: type mismatch: got (MatchingType)
|
texplain.nim(123, 2) Error: type mismatch: got <MatchingType>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc f(o: NestedConcept)
|
proc f(o: NestedConcept)
|
||||||
texplain.nim(73, 6) RegularConcept: undeclared field: 'foo'
|
texplain.nim(73, 6) RegularConcept: undeclared field: 'foo'
|
||||||
|
|
@ -61,7 +61,7 @@ texplain.nim(77, 5) NestedConcept: concept predicate failed
|
||||||
expression: f(y)
|
expression: f(y)
|
||||||
'''
|
'''
|
||||||
line: 123
|
line: 123
|
||||||
errormsg: "type mismatch: got (MatchingType)"
|
errormsg: "type mismatch: got <MatchingType>"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got (string)"
|
errormsg: "type mismatch: got <string>"
|
||||||
line: 21
|
line: 21
|
||||||
nimout: "twrapconcept.nim(11, 5) Foo: concept predicate failed"
|
nimout: "twrapconcept.nim(11, 5) Foo: concept predicate failed"
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got (string, arr: seq[empty])"
|
errormsg: "type mismatch: got <string, arr: seq[empty]>"
|
||||||
line: 15
|
line: 15
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got (proc [*missing parameters*](x: int) | proc (x: string){.gcsafe, locks: 0.})"
|
errormsg: "type mismatch: got <proc [*missing parameters*](x: int) | proc (x: string){.gcsafe, locks: 0.}>"
|
||||||
line: 19
|
line: 19
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ discard """
|
||||||
errormsg: "cannot instantiate B"
|
errormsg: "cannot instantiate B"
|
||||||
line: 20
|
line: 20
|
||||||
nimout: '''
|
nimout: '''
|
||||||
got: (type string)
|
got: <type string>
|
||||||
but expected: (T: A)
|
but expected: <T: A>
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim check $file"
|
cmd: "nim check $file"
|
||||||
errormsg: "type mismatch: got (int literal(1), int literal(2), int literal(3))"
|
errormsg: "type mismatch: got <int literal(1), int literal(2), int literal(3)>"
|
||||||
nimout: '''
|
nimout: '''
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc main(a, b, c: string)
|
proc main(a, b, c: string)
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ discard """
|
||||||
errormsg: "cannot instantiate B"
|
errormsg: "cannot instantiate B"
|
||||||
line: 14
|
line: 14
|
||||||
nimout: '''
|
nimout: '''
|
||||||
got: (type int)
|
got: <type int>
|
||||||
but expected: (T: string or float)
|
but expected: <T: string or float>
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: '''got (tuple of (type NimEdAppWindow, int))'''
|
errormsg: '''got <tuple of (type NimEdAppWindow, int)>'''
|
||||||
line: 22
|
line: 22
|
||||||
nimout: '''got (tuple of (type NimEdAppWindow, int))
|
nimout: '''got <tuple of (type NimEdAppWindow, int)>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
template xxx(tn: typedesc; i: int)'''
|
template xxx(tn: typedesc; i: int)'''
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got (int) but expected 'cshort = int16'"
|
errormsg: "type mismatch: got <int> but expected 'cshort = int16'"
|
||||||
line: 12
|
line: 12
|
||||||
column: 10
|
column: 10
|
||||||
file: "tshow_asgn.nim"
|
file: "tshow_asgn.nim"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got (Future[system.int], void)"
|
errormsg: "type mismatch: got <Future[system.int], void>"
|
||||||
line: 20
|
line: 20
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got (PTest)"
|
errormsg: "type mismatch: got <PTest>"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
line: 16
|
line: 16
|
||||||
errormsg: "type mismatch: got (void)"
|
errormsg: "type mismatch: got <void>"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# bug #950
|
# bug #950
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got (FooRef[system.string])"
|
errormsg: "type mismatch: got <FooRef[system.string]>"
|
||||||
line: 15
|
line: 15
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
line: 6
|
line: 6
|
||||||
errormsg: "type mismatch: got (int literal(1)) but expected 'bool'"
|
errormsg: "type mismatch: got <int literal(1)> but expected 'bool'"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if 1:
|
if 1:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tnocontains.nim"
|
file: "tnocontains.nim"
|
||||||
line: 10
|
line: 10
|
||||||
errormsg: "type mismatch: got (string, string)"
|
errormsg: "type mismatch: got <string, string>"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# shouldn't compile since it doesn't do what you think it does without
|
# shouldn't compile since it doesn't do what you think it does without
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
line: 16
|
line: 16
|
||||||
errormsg: "type mismatch: got (BPtr) but expected 'APtr = ptr[RegionA, int]'"
|
errormsg: "type mismatch: got <BPtr> but expected 'APtr = ptr[RegionA, int]'"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
line: 6
|
line: 6
|
||||||
errormsg: "type mismatch: got (type int)"
|
errormsg: "type mismatch: got <type int>"
|
||||||
"""
|
"""
|
||||||
# bug #3079, #1146
|
# bug #3079, #1146
|
||||||
echo repr(int)
|
echo repr(int)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
file: "ttypenoval.nim"
|
file: "ttypenoval.nim"
|
||||||
line: 38
|
line: 38
|
||||||
errormsg: "type mismatch: got (type int) but expected 'int'"
|
errormsg: "type mismatch: got <type int> but expected 'int'"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# A min-heap.
|
# A min-heap.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue