diff options
author | Araq <rumpf_a@web.de> | 2013-05-04 02:22:38 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-05-04 02:22:38 +0200 |
commit | 3aa36a85680d85e063c9b1f776300bada69cb79f (patch) | |
tree | f5b3f6afcc09f6e8af8ce6970c746fb1bffb4b93 /compiler | |
parent | 0991706d55dabad35f33f7d048ce1b018f6c5b2d (diff) | |
download | Nim-3aa36a85680d85e063c9b1f776300bada69cb79f.tar.gz |
bugfixes
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/cgen.nim | 1 | ||||
-rw-r--r-- | compiler/semexprs.nim | 6 | ||||
-rw-r--r-- | compiler/semstmts.nim | 13 |
3 files changed, 18 insertions, 2 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index cb796e456..f09252b48 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -600,6 +600,7 @@ proc loadDynamicLib(m: BModule, lib: PLib) = [loadlib, getStrLit(m, lib.path.strVal)]) else: var p = newProc(nil, m) + p.options = p.options - {optStackTrace, optEndb} var dest: TLoc initLocExpr(p, lib.path, dest) app(m.s[cfsVars], p.s(cpsLocals)) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index cba4ed081..71e44aa43 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1146,6 +1146,12 @@ proc semProcBody(c: PContext, n: PNode): PNode = # discard it. This is bad for chaining but nicer for C wrappers. # ambiguous :-( result.typ = nil + elif result.kind == nkStmtListExpr and result.typ.kind == tyNil: + # to keep backwards compatibility bodies like: + # nil + # # comment + # are not expressions: + fixNilType(result) else: var a = newNodeI(nkAsgn, n.info, 2) a.sons[0] = newSymNode(c.p.resultSym) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 2811c107a..4146b69a1 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -103,7 +103,16 @@ proc semExprBranchScope(c: PContext, n: PNode): PNode = result = semExprBranch(c, n) closeScope(c.tab) +proc meaningfulStmt(n: PNode): PNode = + assert n.kind == nkStmtListExpr + var last = n.len-1 + while last > 0 and n.sons[last].kind in {nkPragma, nkCommentStmt, nkEmpty}: + dec last + result = n.sons[last] + proc ImplicitlyDiscardable(n: PNode): bool = + var n = n + while n.kind == nkStmtListExpr: n = meaningfulStmt(n) result = isCallExpr(n) and n.sons[0].kind == nkSym and sfDiscardable in n.sons[0].sym.flags @@ -115,6 +124,8 @@ proc fixNilType(n: PNode) = for it in n: fixNilType(it) n.typ = nil +var EnforceVoidContext = PType(kind: tyStmt) + proc discardCheck(result: PNode) = if result.typ != nil and result.typ.kind notin {tyStmt, tyEmpty}: if result.kind == nkNilLit: @@ -1060,8 +1071,6 @@ proc semStaticStmt(c: PContext, n: PNode): PNode = result = newNodeI(nkDiscardStmt, n.info, 1) result.sons[0] = emptyNode -var EnforceVoidContext = PType(kind: tyStmt) - proc semStmtList(c: PContext, n: PNode): PNode = # these must be last statements in a block: const |