diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 96ec12f9a9cb8..8236ecde2986d 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -269,7 +269,7 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors): const errTypeMismatch = "type mismatch: got <" - errButExpected = "but expected one of: " + errButExpected = "but expected one of:" errUndeclaredField = "undeclared field: '$1'" errUndeclaredRoutine = "attempting to call undeclared routine: '$1'" errBadRoutine = "attempting to call routine: '$1'$2" @@ -338,7 +338,9 @@ proc getMsgDiagnostic(c: PContext, flags: TExprFlags, n, f: PNode): string = discard else: typeHint = " for type " & getProcHeader(c.config, sym) - result = errUndeclaredField % ident & typeHint & " " & result + if result.len > 0: + result = " " & result + result = errUndeclaredField % ident & typeHint & result else: if result.len == 0: result = errUndeclaredRoutine % ident else: result = errBadRoutine % [ident, result] diff --git a/testament/testament.nim b/testament/testament.nim index 3e9f04bcc57ea..51d85eae862ff 100644 --- a/testament/testament.nim +++ b/testament/testament.nim @@ -263,6 +263,21 @@ Tests failed and allowed to fail: $3 / $1
Tests skipped: $4 / $1
""" % [$x.total, $x.passed, $x.failedButAllowed, $x.skipped] +import std/tempfiles +proc showDiff(a, b: string) = + # PRTEMP FACTOR MOVE std/private/gitutils.nim + let (fda, patha) = createTempFile("", "") + let (fdb, pathb) = createTempFile("", "") + defer: + close fda + removeFile(patha) + close fdb + removeFile(pathb) + writeFile(patha, a) + writeFile(pathb, b) + # discard execShellCmd("diff -uNdr $1 $2" % [patha.quoteShell, pathb.quoteShell]) + discard execShellCmd("git diff --no-index $1 $2" % [patha.quoteShell, pathb.quoteShell]) + proc addResult(r: var TResults, test: TTest, target: TTarget, expected, given: string, successOrig: TResultEnum, allowFailure = false) = # test.name is easier to find than test.name.extractFilename @@ -303,11 +318,11 @@ proc addResult(r: var TResults, test: TTest, target: TTarget, # expected is empty, no reason to print it. echo given else: - maybeStyledEcho fgYellow, "Expected:" - maybeStyledEcho styleBright, expected, "\n" - maybeStyledEcho fgYellow, "Gotten:" - maybeStyledEcho styleBright, given, "\n" - + # maybeStyledEcho fgYellow, "Expected:" + # maybeStyledEcho styleBright, expected, "\n" + # maybeStyledEcho fgYellow, "Gotten:" + # maybeStyledEcho styleBright, given, "\n" + showDiff(expected, given) if backendLogging and (isAppVeyor or isAzure): let (outcome, msg) = diff --git a/tests/concepts/texplain.nim b/tests/concepts/texplain.nim index 49eb8eb6b1e66..67f4d3ce3df13 100644 --- a/tests/concepts/texplain.nim +++ b/tests/concepts/texplain.nim @@ -13,14 +13,10 @@ proc e(o: ExplainedConcept): int required type for o: ExplainedConcept but expression '10' is of type: int literal(10) texplain.nim(128, 6) ExplainedConcept: undeclared field: 'foo' -texplain.nim(128, 6) ExplainedConcept: undeclared field: '.' -texplain.nim(128, 6) ExplainedConcept: expression '.' cannot be called -texplain.nim(128, 6) ExplainedConcept: expression '' has no type (or is ambiguous) +texplain.nim(128, 6) ExplainedConcept: expression 'error' has no type (or is ambiguous) texplain.nim(128, 5) ExplainedConcept: concept predicate failed texplain.nim(129, 6) ExplainedConcept: undeclared field: 'bar' -texplain.nim(129, 6) ExplainedConcept: undeclared field: '.' -texplain.nim(129, 6) ExplainedConcept: expression '.' cannot be called -texplain.nim(129, 6) ExplainedConcept: expression '' has no type (or is ambiguous) +texplain.nim(129, 6) ExplainedConcept: expression 'error' has no type (or is ambiguous) texplain.nim(128, 5) ExplainedConcept: concept predicate failed texplain.nim(168, 10) Hint: Non-matching candidates for e(10) @@ -29,14 +25,10 @@ proc e(o: ExplainedConcept): int required type for o: ExplainedConcept but expression '10' is of type: int literal(10) texplain.nim(128, 6) ExplainedConcept: undeclared field: 'foo' -texplain.nim(128, 6) ExplainedConcept: undeclared field: '.' -texplain.nim(128, 6) ExplainedConcept: expression '.' cannot be called -texplain.nim(128, 6) ExplainedConcept: expression '' has no type (or is ambiguous) +texplain.nim(128, 6) ExplainedConcept: expression 'error' has no type (or is ambiguous) texplain.nim(128, 5) ExplainedConcept: concept predicate failed texplain.nim(129, 6) ExplainedConcept: undeclared field: 'bar' -texplain.nim(129, 6) ExplainedConcept: undeclared field: '.' -texplain.nim(129, 6) ExplainedConcept: expression '.' cannot be called -texplain.nim(129, 6) ExplainedConcept: expression '' has no type (or is ambiguous) +texplain.nim(129, 6) ExplainedConcept: expression 'error' has no type (or is ambiguous) texplain.nim(128, 5) ExplainedConcept: concept predicate failed texplain.nim(172, 20) Error: type mismatch: got @@ -88,14 +80,10 @@ proc f(o: NestedConcept) required type for o: NestedConcept but expression 'y' is of type: MatchingType texplain.nim(132, 6) RegularConcept: undeclared field: 'foo' -texplain.nim(132, 6) RegularConcept: undeclared field: '.' -texplain.nim(132, 6) RegularConcept: expression '.' cannot be called -texplain.nim(132, 6) RegularConcept: expression '' has no type (or is ambiguous) +texplain.nim(132, 6) RegularConcept: expression 'error' has no type (or is ambiguous) texplain.nim(132, 5) RegularConcept: concept predicate failed texplain.nim(133, 6) RegularConcept: undeclared field: 'bar' -texplain.nim(133, 6) RegularConcept: undeclared field: '.' -texplain.nim(133, 6) RegularConcept: expression '.' cannot be called -texplain.nim(133, 6) RegularConcept: expression '' has no type (or is ambiguous) +texplain.nim(133, 6) RegularConcept: expression 'error' has no type (or is ambiguous) texplain.nim(132, 5) RegularConcept: concept predicate failed texplain.nim(136, 5) NestedConcept: concept predicate failed @@ -121,7 +109,19 @@ expression: f(y)''' -# line 120 HERE + + + + + + + + + + + + +# line 124 HERE type ExplainedConcept {.explain.} = concept o diff --git a/tests/errmsgs/tsigmatch2.nim b/tests/errmsgs/tsigmatch2.nim index 4996634c93e80..07819ce830bb6 100644 --- a/tests/errmsgs/tsigmatch2.nim +++ b/tests/errmsgs/tsigmatch2.nim @@ -13,7 +13,7 @@ proc foo(i: Foo): string but expression '1.2' is of type: float64 expression: foo(1.2) -tsigmatch2.nim(40, 14) Error: expression '' has no type (or is ambiguous) +tsigmatch2.nim(40, 14) Error: expression 'error' has no type (or is ambiguous) tsigmatch2.nim(46, 7) Error: type mismatch: got but expected one of: proc foo(args: varargs[string, myproc]) @@ -44,4 +44,3 @@ block: let temp = 12.isNil proc foo(args: varargs[string, myproc]) = discard foo 1 -static: echo "done" \ No newline at end of file diff --git a/tests/errmsgs/tundeclared_routine.nim b/tests/errmsgs/tundeclared_routine.nim index 2f1320fff51ab..0cca27681a4b5 100644 --- a/tests/errmsgs/tundeclared_routine.nim +++ b/tests/errmsgs/tundeclared_routine.nim @@ -5,18 +5,18 @@ nimout: ''' tundeclared_routine.nim(24, 17) Error: attempting to call routine: 'myiter' found tundeclared_routine.myiter(a: string) [iterator declared in tundeclared_routine.nim(22, 12)] found tundeclared_routine.myiter() [iterator declared in tundeclared_routine.nim(23, 12)] +tundeclared_routine.nim(24, 17) Error: expression 'error' has no type (or is ambiguous) tundeclared_routine.nim(29, 28) Error: invalid pragma: myPragma tundeclared_routine.nim(36, 13) Error: undeclared field: 'bar3' for type tundeclared_routine.Foo [type declared in tundeclared_routine.nim(33, 8)] found tundeclared_routine.bar3() [iterator declared in tundeclared_routine.nim(35, 12)] +tundeclared_routine.nim(36, 13) Error: expression 'error' has no type (or is ambiguous) tundeclared_routine.nim(41, 13) Error: undeclared field: 'bar4' for type tundeclared_routine.Foo [type declared in tundeclared_routine.nim(39, 8)] -tundeclared_routine.nim(44, 15) Error: attempting to call routine: 'bad5' +tundeclared_routine.nim(41, 13) Error: expression 'error' has no type (or is ambiguous) +tundeclared_routine.nim(44, 11) Error: undeclared identifier: 'bad5' ''' """ - - - # line 20 block: iterator myiter(a:string): int = discard diff --git a/tests/objects/t17437.nim b/tests/objects/t17437.nim index b5c0e0525405c..b825d97a5472f 100644 --- a/tests/objects/t17437.nim +++ b/tests/objects/t17437.nim @@ -1,12 +1,12 @@ discard """ - cmd: "nim check $file" + cmd: "nim check --hints:off $file" errormsg: "" nimout: ''' t17437.nim(20, 16) Error: undeclared identifier: 'x' -t17437.nim(20, 16) Error: expression 'x' has no type (or is ambiguous) +t17437.nim(20, 16) Error: expression 'error x' has no type (or is ambiguous) t17437.nim(20, 19) Error: incorrect object construction syntax t17437.nim(20, 19) Error: incorrect object construction syntax -t17437.nim(20, 12) Error: expression '' has no type (or is ambiguous) +t17437.nim(20, 12) Error: expression 'error' has no type (or is ambiguous) ''' """ @@ -17,6 +17,6 @@ type x, y: int proc m = - var v = V(x: x, y) + var v = V(x: x, y) # PRTEMP error x m()