more chatty error message for the 'discard' checking
This commit is contained in:
parent
e2cf3b94f2
commit
d72578b3dd
2 changed files with 5 additions and 2 deletions
|
|
@ -150,9 +150,12 @@ proc discardCheck(c: PContext, result: PNode) =
|
||||||
while n.kind in skipForDiscardable: n = n.lastSon
|
while n.kind in skipForDiscardable: n = n.lastSon
|
||||||
var s = "expression '" & $n & "' is of type '" &
|
var s = "expression '" & $n & "' is of type '" &
|
||||||
result.typ.typeToString & "' and has to be discarded"
|
result.typ.typeToString & "' and has to be discarded"
|
||||||
|
if result.info.line != n.info.line or
|
||||||
|
result.info.fileIndex != n.info.fileIndex:
|
||||||
|
s.add "; start of expression here: " & $result.info
|
||||||
if result.typ.kind == tyProc:
|
if result.typ.kind == tyProc:
|
||||||
s.add "; for a function call use ()"
|
s.add "; for a function call use ()"
|
||||||
localError(n.info, s)
|
localError(n.info, s)
|
||||||
|
|
||||||
proc semIf(c: PContext, n: PNode): PNode =
|
proc semIf(c: PContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
line: 10
|
line: 10
|
||||||
errormsg: '''expression 'open(f, "arg.txt", fmRead, -1)' is of type 'bool' and has to be discarded'''
|
errormsg: '''expression 'open(f, "arg.txt", fmRead, -1)' is of type 'bool' and has to be discarded; start of expression here: tneedsdiscard.nim(7, 2)'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc p =
|
proc p =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue