improve the 'has to be discarded' error message

This commit is contained in:
Araq 2020-05-02 14:37:16 +02:00 • committed by Andreas Rumpf
commit 7f1d2489ad
5 changed files with 6 additions and 6 deletions

View file

@ -12,7 +12,7 @@
const
errNoSymbolToBorrowFromFound = "no symbol to borrow from found"
errDiscardValueX = "value of type '$1' has to be discarded"
errDiscardValueX = "value of type '$1' has to be used (or discarded)"
errInvalidDiscard = "statement returns no value that can be discarded"
errInvalidControlFlowX = "invalid control flow: $1"
errSelectorMustBeOfCertainTypes = "selector must be of an ordinal type, float or string"
@ -144,7 +144,7 @@ proc discardCheck(c: PContext, result: PNode, flags: TExprFlags) =
var n = result
while n.kind in skipForDiscardable: n = n.lastSon
var s = "expression '" & $n & "' is of type '" &
result.typ.typeToString & "' and has to be discarded"
result.typ.typeToString & "' and has to be used (or discarded)"
if result.info.line != n.info.line or
result.info.fileIndex != n.info.fileIndex:
s.add "; start of expression here: " & c.config$result.info