parent
9874981e75
commit
73eff1f457
4 changed files with 55 additions and 47 deletions
|
|
@ -62,12 +62,18 @@ proc semOperand(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
renderTree(result, {renderNoComments}))
|
renderTree(result, {renderNoComments}))
|
||||||
result.typ = errorType(c)
|
result.typ = errorType(c)
|
||||||
|
|
||||||
proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
proc semExprCheck(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
rejectEmptyNode(n)
|
rejectEmptyNode(n)
|
||||||
result = semExpr(c, n, flags+{efWantValue})
|
result = semExpr(c, n, flags+{efWantValue})
|
||||||
if result.kind == nkEmpty:
|
if result.kind == nkEmpty:
|
||||||
|
# bug #12741, redundant error messages are the lesser evil here:
|
||||||
|
localError(c.config, n.info, errExprXHasNoType %
|
||||||
|
renderTree(result, {renderNoComments}))
|
||||||
# do not produce another redundant error message:
|
# do not produce another redundant error message:
|
||||||
result = errorNode(c, n)
|
result = errorNode(c, n)
|
||||||
|
|
||||||
|
proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
|
result = semExprCheck(c, n, flags)
|
||||||
if result.typ == nil or result.typ == c.enforceVoidContext:
|
if result.typ == nil or result.typ == c.enforceVoidContext:
|
||||||
localError(c.config, n.info, errExprXHasNoType %
|
localError(c.config, n.info, errExprXHasNoType %
|
||||||
renderTree(result, {renderNoComments}))
|
renderTree(result, {renderNoComments}))
|
||||||
|
|
@ -76,11 +82,7 @@ proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
if result.typ.kind in {tyVar, tyLent}: result = newDeref(result)
|
if result.typ.kind in {tyVar, tyLent}: result = newDeref(result)
|
||||||
|
|
||||||
proc semExprNoDeref(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
proc semExprNoDeref(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
rejectEmptyNode(n)
|
result = semExprCheck(c, n, flags)
|
||||||
result = semExpr(c, n, flags+{efWantValue})
|
|
||||||
if result.kind == nkEmpty:
|
|
||||||
# do not produce another redundant error message:
|
|
||||||
result = errorNode(c, n)
|
|
||||||
if result.typ == nil:
|
if result.typ == nil:
|
||||||
localError(c.config, n.info, errExprXHasNoType %
|
localError(c.config, n.info, errExprXHasNoType %
|
||||||
renderTree(result, {renderNoComments}))
|
renderTree(result, {renderNoComments}))
|
||||||
|
|
@ -192,7 +194,7 @@ proc isCastable(conf: ConfigRef; dst, src: PType): bool =
|
||||||
if conf.selectedGC in {gcArc, gcOrc}:
|
if conf.selectedGC in {gcArc, gcOrc}:
|
||||||
let d = skipTypes(dst, abstractInst)
|
let d = skipTypes(dst, abstractInst)
|
||||||
let s = skipTypes(src, abstractInst)
|
let s = skipTypes(src, abstractInst)
|
||||||
if d.kind == tyRef and s.kind == tyRef and s[0].isFinal != d[0].isFinal:
|
if d.kind == tyRef and s.kind == tyRef and s[0].isFinal != d[0].isFinal:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
var dstSize, srcSize: BiggestInt
|
var dstSize, srcSize: BiggestInt
|
||||||
|
|
|
||||||
|
|
@ -1476,9 +1476,9 @@ proc semProcAnnotation(c: PContext, prc: PNode;
|
||||||
let ident = considerQuotedIdent(c, key)
|
let ident = considerQuotedIdent(c, key)
|
||||||
if strTableGet(c.userPragmas, ident) != nil:
|
if strTableGet(c.userPragmas, ident) != nil:
|
||||||
continue # User defined pragma
|
continue # User defined pragma
|
||||||
else:
|
else:
|
||||||
let sym = searchInScopes(c, ident)
|
let sym = searchInScopes(c, ident)
|
||||||
if sym != nil and sfCustomPragma in sym.flags:
|
if sym != nil and sfCustomPragma in sym.flags:
|
||||||
continue # User custom pragma
|
continue # User custom pragma
|
||||||
|
|
||||||
# we transform ``proc p {.m, rest.}`` into ``m(do: proc p {.rest.})`` and
|
# we transform ``proc p {.m, rest.}`` into ``m(do: proc p {.rest.})`` and
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,45 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim c --verbosity:0 --colors:off $file"
|
cmd: "nim c --verbosity:0 --colors:off $file"
|
||||||
nimout: '''
|
nimout: '''
|
||||||
texplain.nim(158, 10) Hint: Non-matching candidates for e(y)
|
texplain.nim(164, 10) Hint: Non-matching candidates for e(y)
|
||||||
proc e(i: int): int
|
proc e(i: int): int
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
required type for i: int
|
required type for i: int
|
||||||
but expression 'y' is of type: MatchingType
|
but expression 'y' is of type: MatchingType
|
||||||
|
|
||||||
texplain.nim(161, 7) Hint: Non-matching candidates for e(10)
|
texplain.nim(167, 7) Hint: Non-matching candidates for e(10)
|
||||||
proc e(o: ExplainedConcept): int
|
proc e(o: ExplainedConcept): int
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
required type for o: ExplainedConcept
|
required type for o: ExplainedConcept
|
||||||
but expression '10' is of type: int literal(10)
|
but expression '10' is of type: int literal(10)
|
||||||
texplain.nim(124, 6) ExplainedConcept: undeclared field: 'foo'
|
texplain.nim(130, 6) ExplainedConcept: undeclared field: 'foo'
|
||||||
texplain.nim(124, 6) ExplainedConcept: undeclared field: '.'
|
texplain.nim(130, 6) ExplainedConcept: undeclared field: '.'
|
||||||
texplain.nim(124, 6) ExplainedConcept: expression '.' cannot be called
|
texplain.nim(130, 6) ExplainedConcept: expression '.' cannot be called
|
||||||
texplain.nim(124, 5) ExplainedConcept: concept predicate failed
|
texplain.nim(130, 6) ExplainedConcept: expression '' has no type (or is ambiguous)
|
||||||
texplain.nim(125, 6) ExplainedConcept: undeclared field: 'bar'
|
texplain.nim(130, 5) ExplainedConcept: concept predicate failed
|
||||||
texplain.nim(125, 6) ExplainedConcept: undeclared field: '.'
|
texplain.nim(131, 6) ExplainedConcept: undeclared field: 'bar'
|
||||||
texplain.nim(125, 6) ExplainedConcept: expression '.' cannot be called
|
texplain.nim(131, 6) ExplainedConcept: undeclared field: '.'
|
||||||
texplain.nim(124, 5) ExplainedConcept: concept predicate failed
|
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(164, 10) Hint: Non-matching candidates for e(10)
|
texplain.nim(170, 10) Hint: Non-matching candidates for e(10)
|
||||||
proc e(o: ExplainedConcept): int
|
proc e(o: ExplainedConcept): int
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
required type for o: ExplainedConcept
|
required type for o: ExplainedConcept
|
||||||
but expression '10' is of type: int literal(10)
|
but expression '10' is of type: int literal(10)
|
||||||
texplain.nim(124, 6) ExplainedConcept: undeclared field: 'foo'
|
texplain.nim(130, 6) ExplainedConcept: undeclared field: 'foo'
|
||||||
texplain.nim(124, 6) ExplainedConcept: undeclared field: '.'
|
texplain.nim(130, 6) ExplainedConcept: undeclared field: '.'
|
||||||
texplain.nim(124, 6) ExplainedConcept: expression '.' cannot be called
|
texplain.nim(130, 6) ExplainedConcept: expression '.' cannot be called
|
||||||
texplain.nim(124, 5) ExplainedConcept: concept predicate failed
|
texplain.nim(130, 6) ExplainedConcept: expression '' has no type (or is ambiguous)
|
||||||
texplain.nim(125, 6) ExplainedConcept: undeclared field: 'bar'
|
texplain.nim(130, 5) ExplainedConcept: concept predicate failed
|
||||||
texplain.nim(125, 6) ExplainedConcept: undeclared field: '.'
|
texplain.nim(131, 6) ExplainedConcept: undeclared field: 'bar'
|
||||||
texplain.nim(125, 6) ExplainedConcept: expression '.' cannot be called
|
texplain.nim(131, 6) ExplainedConcept: undeclared field: '.'
|
||||||
texplain.nim(124, 5) ExplainedConcept: concept predicate failed
|
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(168, 20) Error: type mismatch: got <NonMatchingType>
|
texplain.nim(174, 20) Error: type mismatch: got <NonMatchingType>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc e(i: int): int
|
proc e(i: int): int
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
|
|
@ -45,11 +49,11 @@ proc e(o: ExplainedConcept): int
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
required type for o: ExplainedConcept
|
required type for o: ExplainedConcept
|
||||||
but expression 'n' is of type: NonMatchingType
|
but expression 'n' is of type: NonMatchingType
|
||||||
texplain.nim(168, 9) template/generic instantiation of `assert` from here
|
texplain.nim(174, 9) template/generic instantiation of `assert` from here
|
||||||
texplain.nim(124, 5) ExplainedConcept: concept predicate failed
|
texplain.nim(130, 5) ExplainedConcept: concept predicate failed
|
||||||
|
|
||||||
expression: e(n)
|
expression: e(n)
|
||||||
texplain.nim(169, 20) Error: type mismatch: got <NonMatchingType>
|
texplain.nim(175, 20) Error: type mismatch: got <NonMatchingType>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc r(i: string): int
|
proc r(i: string): int
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
|
|
@ -59,15 +63,15 @@ proc r(o: RegularConcept): int
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
required type for o: RegularConcept
|
required type for o: RegularConcept
|
||||||
but expression 'n' is of type: NonMatchingType
|
but expression 'n' is of type: NonMatchingType
|
||||||
texplain.nim(169, 9) template/generic instantiation of `assert` from here
|
texplain.nim(175, 9) template/generic instantiation of `assert` from here
|
||||||
texplain.nim(128, 5) RegularConcept: concept predicate failed
|
texplain.nim(134, 5) RegularConcept: concept predicate failed
|
||||||
proc r[T](a: SomeNumber; b: T; c: auto)
|
proc r[T](a: SomeNumber; b: T; c: auto)
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
required type for a: SomeNumber
|
required type for a: SomeNumber
|
||||||
but expression 'n' is of type: NonMatchingType
|
but expression 'n' is of type: NonMatchingType
|
||||||
|
|
||||||
expression: r(n)
|
expression: r(n)
|
||||||
texplain.nim(170, 20) Hint: Non-matching candidates for r(y)
|
texplain.nim(176, 20) Hint: Non-matching candidates for r(y)
|
||||||
proc r(i: string): int
|
proc r(i: string): int
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
required type for i: string
|
required type for i: string
|
||||||
|
|
@ -77,25 +81,27 @@ proc r[T](a: SomeNumber; b: T; c: auto)
|
||||||
required type for a: SomeNumber
|
required type for a: SomeNumber
|
||||||
but expression 'y' is of type: MatchingType
|
but expression 'y' is of type: MatchingType
|
||||||
|
|
||||||
texplain.nim(178, 2) Error: type mismatch: got <MatchingType>
|
texplain.nim(184, 2) Error: type mismatch: got <MatchingType>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc f(o: NestedConcept)
|
proc f(o: NestedConcept)
|
||||||
first type mismatch at position: 1
|
first type mismatch at position: 1
|
||||||
required type for o: NestedConcept
|
required type for o: NestedConcept
|
||||||
but expression 'y' is of type: MatchingType
|
but expression 'y' is of type: MatchingType
|
||||||
texplain.nim(128, 6) RegularConcept: undeclared field: 'foo'
|
texplain.nim(134, 6) RegularConcept: undeclared field: 'foo'
|
||||||
texplain.nim(128, 6) RegularConcept: undeclared field: '.'
|
texplain.nim(134, 6) RegularConcept: undeclared field: '.'
|
||||||
texplain.nim(128, 6) RegularConcept: expression '.' cannot be called
|
texplain.nim(134, 6) RegularConcept: expression '.' cannot be called
|
||||||
texplain.nim(128, 5) RegularConcept: concept predicate failed
|
texplain.nim(134, 6) RegularConcept: expression '' has no type (or is ambiguous)
|
||||||
texplain.nim(129, 6) RegularConcept: undeclared field: 'bar'
|
texplain.nim(134, 5) RegularConcept: concept predicate failed
|
||||||
texplain.nim(129, 6) RegularConcept: undeclared field: '.'
|
texplain.nim(135, 6) RegularConcept: undeclared field: 'bar'
|
||||||
texplain.nim(129, 6) RegularConcept: expression '.' cannot be called
|
texplain.nim(135, 6) RegularConcept: undeclared field: '.'
|
||||||
texplain.nim(128, 5) RegularConcept: concept predicate failed
|
texplain.nim(135, 6) RegularConcept: expression '.' cannot be called
|
||||||
texplain.nim(132, 5) NestedConcept: concept predicate failed
|
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)'''
|
expression: f(y)'''
|
||||||
errormsg: "type mismatch: got <MatchingType>"
|
errormsg: "type mismatch: got <MatchingType>"
|
||||||
line: 178
|
line: 184
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ proc foo(i: Foo): string
|
||||||
but expression '1.2' is of type: float64
|
but expression '1.2' is of type: float64
|
||||||
|
|
||||||
expression: foo(1.2)
|
expression: foo(1.2)
|
||||||
|
tsigmatch2.nim(40, 14) Error: expression '' has no type (or is ambiguous)
|
||||||
tsigmatch2.nim(46, 7) Error: type mismatch: got <int literal(1)>
|
tsigmatch2.nim(46, 7) Error: type mismatch: got <int literal(1)>
|
||||||
but expected one of:
|
but expected one of:
|
||||||
proc foo(args: varargs[string, myproc])
|
proc foo(args: varargs[string, myproc])
|
||||||
|
|
@ -26,7 +27,6 @@ expression: foo 1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# line 30
|
# line 30
|
||||||
type Foo = object
|
type Foo = object
|
||||||
block: # issue #13182
|
block: # issue #13182
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue