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",
|
||||
errVarForOutParamNeededX: "for a \'var\' type a variable needs to be passed; but '$1' is immutable",
|
||||
errPureTypeMismatch: "type mismatch",
|
||||
errTypeMismatch: "type mismatch: got (",
|
||||
errTypeMismatch: "type mismatch: got <",
|
||||
errButExpected: "but expected one of: ",
|
||||
errButExpectedX: "but expected \'$1\'",
|
||||
errAmbiguousCallXYZ: "ambiguous call; both $1 and $2 match for: $3",
|
||||
|
|
|
|||
|
|
@ -156,14 +156,14 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
|
|||
add(candidates, err.sym.getProcHeader(prefer))
|
||||
add(candidates, "\n")
|
||||
if err.firstMismatch != 0 and n.len > 2:
|
||||
add(candidates, "first type mismatch at position: " & $err.firstMismatch &
|
||||
"\nrequired type: ")
|
||||
add(candidates, " first type mismatch at position: " & $err.firstMismatch &
|
||||
"\n required type: ")
|
||||
if err.firstMismatch < err.sym.typ.len:
|
||||
candidates.add typeToString(err.sym.typ.sons[err.firstMismatch])
|
||||
else:
|
||||
candidates.add "none"
|
||||
if err.firstMismatch < n.len:
|
||||
candidates.add "\nbut expression '"
|
||||
candidates.add "\n but expression '"
|
||||
candidates.add renderTree(n[err.firstMismatch])
|
||||
candidates.add "' is of type: "
|
||||
candidates.add typeToString(n[err.firstMismatch].typ)
|
||||
|
|
@ -190,7 +190,7 @@ proc notFoundError*(c: PContext, n: PNode, errors: CandidateErrors) =
|
|||
let (prefer, candidates) = presentFailedCandidates(c, n, errors)
|
||||
var result = msgKindToString(errTypeMismatch)
|
||||
add(result, describeArgs(c, n, 1, prefer))
|
||||
add(result, ')')
|
||||
add(result, '>')
|
||||
if candidates != "":
|
||||
add(result, "\n" & msgKindToString(errButExpected) & "\n" & candidates)
|
||||
localError(n.info, errGenerated, result & "\nexpression: " & $n)
|
||||
|
|
|
|||
|
|
@ -735,7 +735,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
hasErrorType = true
|
||||
break
|
||||
if not hasErrorType:
|
||||
add(msg, ")\n" & msgKindToString(errButExpected) & "\n" &
|
||||
add(msg, ">\n" & msgKindToString(errButExpected) & "\n" &
|
||||
typeToString(n.sons[0].typ))
|
||||
localError(n.info, errGenerated, msg)
|
||||
return errorNode(c, n)
|
||||
|
|
|
|||
|
|
@ -1149,8 +1149,8 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
|
|||
|
||||
if m.state != csMatch:
|
||||
let err = "cannot instantiate " & typeToString(t) & "\n" &
|
||||
"got: (" & describeArgs(c, n) & ")\n" &
|
||||
"but expected: (" & describeArgs(c, t.n, 0) & ")"
|
||||
"got: <" & describeArgs(c, n) & ">\n" &
|
||||
"but expected: <" & describeArgs(c, t.n, 0) & ">"
|
||||
localError(n.info, errGenerated, err)
|
||||
return newOrPrevType(tyError, prev, c)
|
||||
|
||||
|
|
|
|||
|
|
@ -1620,7 +1620,7 @@ proc typeMismatch*(info: TLineInfo, formal, actual: PType) =
|
|||
let desc = typeToString(formal, preferDesc)
|
||||
let x = if named == desc: named else: named & " = " & desc
|
||||
var msg = msgKindToString(errTypeMismatch) &
|
||||
typeToString(actual) & ") " &
|
||||
typeToString(actual) & "> " &
|
||||
msgKindToString(errButExpectedX) % [x]
|
||||
|
||||
if formal.kind == tyProc and actual.kind == tyProc:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue