diff options
Diffstat (limited to 'compiler/semexprs.nim')
-rwxr-xr-x | compiler/semexprs.nim | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index adcd67ea3..2c98d9de6 100755 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -471,7 +471,8 @@ proc analyseIfAddressTaken(c: PContext, n: PNode): PNode = result = n case n.kind of nkSym: - if skipTypes(n.sym.typ, abstractInst).kind != tyVar: + # n.sym.typ can be nil in 'check' mode ... + if n.sym.typ != nil and skipTypes(n.sym.typ, abstractInst).kind != tyVar: incl(n.sym.flags, sfAddrTaken) result = newHiddenAddrTaken(c, n) of nkDotExpr: @@ -722,9 +723,6 @@ proc buildEchoStmt(c: PContext, n: PNode): PNode = addSon(result, semExpr(c, arg)) proc discardCheck(result: PNode) = - proc ImplicitelyDiscardable(n: PNode): bool {.inline.} = - result = isCallExpr(n) and n.sons[0].kind == nkSym and - sfDiscardable in n.sons[0].sym.flags if result.typ != nil and result.typ.kind notin {tyStmt, tyEmpty}: if result.kind == nkNilLit: # XXX too much work and fixing would break bootstrapping: @@ -1104,7 +1102,9 @@ proc semProcBody(c: PContext, n: PNode): PNode = # ``result``: if result.kind == nkSym and result.sym == c.p.resultSym: nil - elif result.kind == nkNilLit: + elif result.kind == nkNilLit or ImplicitelyDiscardable(result): + # intended semantic: if it's 'discardable' and the context allows for it, + # discard it. This is bad for chaining but nicer for C wrappers. # ambiguous :-( result.typ = nil else: |