mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 10:22:15 +00:00
fixes #451
This commit is contained in:
@@ -146,7 +146,9 @@ proc discardCheck(result: PNode) =
|
||||
if result.typ.kind == tyNil:
|
||||
fixNilType(result)
|
||||
else:
|
||||
localError(result.info, errDiscardValue)
|
||||
var n = result
|
||||
while n.kind in skipForDiscardable: n = n.lastSon
|
||||
localError(n.info, errDiscardValue)
|
||||
|
||||
proc semIf(c: PContext, n: PNode): PNode =
|
||||
result = n
|
||||
|
||||
12
tests/reject/tneedsdiscard.nim
Normal file
12
tests/reject/tneedsdiscard.nim
Normal file
@@ -0,0 +1,12 @@
|
||||
discard """
|
||||
line: 10
|
||||
errormsg: "value returned by statement has to be discarded"
|
||||
"""
|
||||
|
||||
proc p =
|
||||
var f: TFile
|
||||
echo "hi"
|
||||
|
||||
open(f, "arg.txt")
|
||||
|
||||
p()
|
||||
Reference in New Issue
Block a user