mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 09:24:36 +00:00
185 lines
6.0 KiB
Nim
185 lines
6.0 KiB
Nim
discard """
|
|
cmd: "nim c --verbosity:0 --colors:off $file"
|
|
nimout: '''
|
|
texplain.nim(164, 10) Hint: Non-matching candidates for e(y)
|
|
proc e(i: int): int
|
|
first type mismatch at position: 1
|
|
required type for i: int
|
|
but expression 'y' is of type: MatchingType
|
|
|
|
texplain.nim(167, 7) Hint: Non-matching candidates for e(10)
|
|
proc e(o: ExplainedConcept): int
|
|
first type mismatch at position: 1
|
|
required type for o: ExplainedConcept
|
|
but expression '10' is of type: int literal(10)
|
|
texplain.nim(130, 6) ExplainedConcept: undeclared field: 'foo'
|
|
texplain.nim(130, 6) ExplainedConcept: undeclared field: '.'
|
|
texplain.nim(130, 6) ExplainedConcept: expression '.' cannot be called
|
|
texplain.nim(130, 6) ExplainedConcept: expression '' has no type (or is ambiguous)
|
|
texplain.nim(130, 5) ExplainedConcept: concept predicate failed
|
|
texplain.nim(131, 6) ExplainedConcept: undeclared field: 'bar'
|
|
texplain.nim(131, 6) ExplainedConcept: undeclared field: '.'
|
|
texplain.nim(131, 6) ExplainedConcept: expression '.' cannot be called
|
|
texplain.nim(131, 6) ExplainedConcept: expression '' has no type (or is ambiguous)
|
|
texplain.nim(130, 5) ExplainedConcept: concept predicate failed
|
|
|
|
texplain.nim(170, 10) Hint: Non-matching candidates for e(10)
|
|
proc e(o: ExplainedConcept): int
|
|
first type mismatch at position: 1
|
|
required type for o: ExplainedConcept
|
|
but expression '10' is of type: int literal(10)
|
|
texplain.nim(130, 6) ExplainedConcept: undeclared field: 'foo'
|
|
texplain.nim(130, 6) ExplainedConcept: undeclared field: '.'
|
|
texplain.nim(130, 6) ExplainedConcept: expression '.' cannot be called
|
|
texplain.nim(130, 6) ExplainedConcept: expression '' has no type (or is ambiguous)
|
|
texplain.nim(130, 5) ExplainedConcept: concept predicate failed
|
|
texplain.nim(131, 6) ExplainedConcept: undeclared field: 'bar'
|
|
texplain.nim(131, 6) ExplainedConcept: undeclared field: '.'
|
|
texplain.nim(131, 6) ExplainedConcept: expression '.' cannot be called
|
|
texplain.nim(131, 6) ExplainedConcept: expression '' has no type (or is ambiguous)
|
|
texplain.nim(130, 5) ExplainedConcept: concept predicate failed
|
|
|
|
texplain.nim(174, 20) Error: type mismatch: got <NonMatchingType>
|
|
but expected one of:
|
|
proc e(i: int): int
|
|
first type mismatch at position: 1
|
|
required type for i: int
|
|
but expression 'n' is of type: NonMatchingType
|
|
proc e(o: ExplainedConcept): int
|
|
first type mismatch at position: 1
|
|
required type for o: ExplainedConcept
|
|
but expression 'n' is of type: NonMatchingType
|
|
texplain.nim(174, 9) template/generic instantiation of `assert` from here
|
|
texplain.nim(130, 5) ExplainedConcept: concept predicate failed
|
|
|
|
expression: e(n)
|
|
texplain.nim(175, 20) Error: type mismatch: got <NonMatchingType>
|
|
but expected one of:
|
|
proc r(i: string): int
|
|
first type mismatch at position: 1
|
|
required type for i: string
|
|
but expression 'n' is of type: NonMatchingType
|
|
proc r(o: RegularConcept): int
|
|
first type mismatch at position: 1
|
|
required type for o: RegularConcept
|
|
but expression 'n' is of type: NonMatchingType
|
|
texplain.nim(175, 9) template/generic instantiation of `assert` from here
|
|
texplain.nim(134, 5) RegularConcept: concept predicate failed
|
|
proc r[T](a: SomeNumber; b: T; c: auto)
|
|
first type mismatch at position: 1
|
|
required type for a: SomeNumber
|
|
but expression 'n' is of type: NonMatchingType
|
|
|
|
expression: r(n)
|
|
texplain.nim(176, 20) Hint: Non-matching candidates for r(y)
|
|
proc r(i: string): int
|
|
first type mismatch at position: 1
|
|
required type for i: string
|
|
but expression 'y' is of type: MatchingType
|
|
proc r[T](a: SomeNumber; b: T; c: auto)
|
|
first type mismatch at position: 1
|
|
required type for a: SomeNumber
|
|
but expression 'y' is of type: MatchingType
|
|
|
|
texplain.nim(184, 2) Error: type mismatch: got <MatchingType>
|
|
but expected one of:
|
|
proc f(o: NestedConcept)
|
|
first type mismatch at position: 1
|
|
required type for o: NestedConcept
|
|
but expression 'y' is of type: MatchingType
|
|
texplain.nim(134, 6) RegularConcept: undeclared field: 'foo'
|
|
texplain.nim(134, 6) RegularConcept: undeclared field: '.'
|
|
texplain.nim(134, 6) RegularConcept: expression '.' cannot be called
|
|
texplain.nim(134, 6) RegularConcept: expression '' has no type (or is ambiguous)
|
|
texplain.nim(134, 5) RegularConcept: concept predicate failed
|
|
texplain.nim(135, 6) RegularConcept: undeclared field: 'bar'
|
|
texplain.nim(135, 6) RegularConcept: undeclared field: '.'
|
|
texplain.nim(135, 6) RegularConcept: expression '.' cannot be called
|
|
texplain.nim(135, 6) RegularConcept: expression '' has no type (or is ambiguous)
|
|
texplain.nim(134, 5) RegularConcept: concept predicate failed
|
|
texplain.nim(138, 5) NestedConcept: concept predicate failed
|
|
|
|
expression: f(y)'''
|
|
errormsg: "type mismatch: got <MatchingType>"
|
|
line: 184
|
|
|
|
"""
|
|
|
|
|
|
|
|
# proc r[T](a: SomeNumber; b: T; c: auto)
|
|
# proc r(i: string): int
|
|
# proc r(o: RegularConcept): int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# line 120 HERE
|
|
|
|
type
|
|
ExplainedConcept {.explain.} = concept o
|
|
o.foo is int
|
|
o.bar is string
|
|
|
|
RegularConcept = concept o
|
|
o.foo is int
|
|
o.bar is string
|
|
|
|
NestedConcept = concept o
|
|
o.foo is RegularConcept
|
|
|
|
NonMatchingType = object
|
|
foo: int
|
|
bar: int
|
|
|
|
MatchingType = object
|
|
foo: int
|
|
bar: string
|
|
|
|
proc e(o: ExplainedConcept): int = 1
|
|
proc e(i: int): int = i
|
|
|
|
proc r[T](a: SomeNumber, b: T, c: auto) = discard
|
|
proc r(o: RegularConcept): int = 1
|
|
proc r(i: string): int = 1
|
|
|
|
proc f(o: NestedConcept) = discard
|
|
|
|
var n = NonMatchingType(foo: 10, bar: 20)
|
|
var y = MatchingType(foo: 10, bar: "bar")
|
|
|
|
# no diagnostic here:
|
|
discard e(y)
|
|
|
|
# explain that e(int) doesn't match
|
|
discard e(y) {.explain.}
|
|
|
|
# explain that e(ExplainedConcept) doesn't match
|
|
echo(e(10) {.explain.}, 20)
|
|
|
|
# explain that e(ExplainedConcept) doesn't again
|
|
discard e(10)
|
|
|
|
static:
|
|
# provide diagnostics why the compile block failed
|
|
assert(compiles(e(n)) {.explain.} == false)
|
|
assert(compiles(r(n)) {.explain.} == false)
|
|
assert(compiles(r(y)) {.explain.} == true)
|
|
|
|
# these should not produce any output
|
|
assert(compiles(r(10)) == false)
|
|
assert(compiles(e(10)) == true)
|
|
|
|
# finally, provide multiple nested explanations for failed matching
|
|
# of regular concepts, even when the explain pragma is not used
|
|
f(y)
|