diff options
author | Araq <rumpf_a@web.de> | 2017-12-27 21:26:37 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-12-27 21:26:37 +0100 |
commit | 0b0baece89883a2d91d9ebbff66538d974ee1fbc (patch) | |
tree | 93c2ca763a4e17b8a7e5356e53fb45775d427b01 /compiler | |
parent | e49f18801c0891221ca76d3a94f5cafa2af40448 (diff) | |
download | Nim-0b0baece89883a2d91d9ebbff66538d974ee1fbc.tar.gz |
fixes #6980
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semexprs.nim | 13 | ||||
-rw-r--r-- | compiler/semstmts.nim | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 55c43ed09..a0f519820 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -780,6 +780,19 @@ proc buildEchoStmt(c: PContext, n: PNode): PNode = proc semExprNoType(c: PContext, n: PNode): PNode = result = semExpr(c, n, {efWantStmt}) + # make an 'if' expression an 'if' statement again for backwards + # compatibility (.discardable was a bad idea!); bug #6980 + var isStmt = false + if result.kind == nkIfExpr: + isStmt = true + for condActionPair in result: + let action = condActionPair.lastSon + if not implicitlyDiscardable(action) and not + endsInNoReturn(action): + isStmt = false + if isStmt: + result.kind = nkIfStmt + result.typ = nil discardCheck(c, result) proc isTypeExpr(n: PNode): bool = diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index b1fa8c19b..dcaa0263b 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -732,7 +732,7 @@ proc semRaise(c: PContext, n: PNode): PNode = var typ = n.sons[0].typ if typ.kind != tyRef or typ.lastSon.kind != tyObject: localError(n.info, errExprCannotBeRaised) - + # check if the given object inherits from Exception var base = typ.lastSon while true: |