remove the deprecated 'nil' statement
This commit is contained in:
parent
599b5d6dcb
commit
5ac94d26b3
1 changed files with 11 additions and 18 deletions
|
|
@ -107,30 +107,23 @@ proc fixNilType(n: PNode) =
|
||||||
proc discardCheck(c: PContext, result: PNode) =
|
proc discardCheck(c: PContext, result: PNode) =
|
||||||
if c.matchedConcept != nil: return
|
if c.matchedConcept != nil: return
|
||||||
if result.typ != nil and result.typ.kind notin {tyStmt, tyVoid}:
|
if result.typ != nil and result.typ.kind notin {tyStmt, tyVoid}:
|
||||||
if result.kind == nkNilLit:
|
if implicitlyDiscardable(result):
|
||||||
result.typ = nil
|
|
||||||
message(result.info, warnNilStatement)
|
|
||||||
elif implicitlyDiscardable(result):
|
|
||||||
var n = result
|
var n = result
|
||||||
result.typ = nil
|
result.typ = nil
|
||||||
while n.kind in skipForDiscardable:
|
while n.kind in skipForDiscardable:
|
||||||
n = n.lastSon
|
n = n.lastSon
|
||||||
n.typ = nil
|
n.typ = nil
|
||||||
elif result.typ.kind != tyError and gCmd != cmdInteractive:
|
elif result.typ.kind != tyError and gCmd != cmdInteractive:
|
||||||
if result.typ.kind == tyNil:
|
var n = result
|
||||||
fixNilType(result)
|
while n.kind in skipForDiscardable: n = n.lastSon
|
||||||
message(result.info, warnNilStatement)
|
var s = "expression '" & $n & "' is of type '" &
|
||||||
else:
|
result.typ.typeToString & "' and has to be discarded"
|
||||||
var n = result
|
if result.info.line != n.info.line or
|
||||||
while n.kind in skipForDiscardable: n = n.lastSon
|
result.info.fileIndex != n.info.fileIndex:
|
||||||
var s = "expression '" & $n & "' is of type '" &
|
s.add "; start of expression here: " & $result.info
|
||||||
result.typ.typeToString & "' and has to be discarded"
|
if result.typ.kind == tyProc:
|
||||||
if result.info.line != n.info.line or
|
s.add "; for a function call use ()"
|
||||||
result.info.fileIndex != n.info.fileIndex:
|
localError(n.info, s)
|
||||||
s.add "; start of expression here: " & $result.info
|
|
||||||
if result.typ.kind == tyProc:
|
|
||||||
s.add "; for a function call use ()"
|
|
||||||
localError(n.info, s)
|
|
||||||
|
|
||||||
proc semIf(c: PContext, n: PNode): PNode =
|
proc semIf(c: PContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue