diff options
author | Araq <rumpf_a@web.de> | 2018-02-10 20:39:05 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-02-10 20:55:21 +0100 |
commit | ef6eda4cb4b28a6c4a2706ea56240bc708e36349 (patch) | |
tree | 9f7596b6a4127d40a146d56bfb25a1f345e2fd8e /compiler | |
parent | 51d81c4e23c7f5513a1b2028f02509c860021278 (diff) | |
download | Nim-ef6eda4cb4b28a6c4a2706ea56240bc708e36349.tar.gz |
better error messages: use <T1, T2> instead of (T1, T2) in order to prevent confusions with tuple types
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/msgs.nim | 2 | ||||
-rw-r--r-- | compiler/semcall.nim | 8 | ||||
-rw-r--r-- | compiler/semexprs.nim | 2 | ||||
-rw-r--r-- | compiler/semtypes.nim | 4 | ||||
-rw-r--r-- | compiler/types.nim | 2 |
5 files changed, 9 insertions, 9 deletions
diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 954883b01..6439d47ee 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -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", diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 01f291017..d8ee6e7a1 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -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) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index d4b1eec88..7f58e266e 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -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) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index f14b40a9b..df274c7db 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -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) diff --git a/compiler/types.nim b/compiler/types.nim index 452e95dfd..10827f830 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -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: |