diff options
author | Zahary Karadjov <zahary@gmail.comy> | 2011-09-07 16:32:43 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.comy> | 2011-09-20 14:13:45 +0300 |
commit | a28cf4e9cbb7e202d355d669d16b86457932ec2a (patch) | |
tree | ba33cecb4ea84e037de27c6c05d470a28b1bb0ca /compiler | |
parent | 9b95ca407d38fecb23a39cf0f6d92ed838e57623 (diff) | |
download | Nim-a28cf4e9cbb7e202d355d669d16b86457932ec2a.tar.gz |
Quick Fix:
Constant expressions used in when statements and tuple indexing are properly evaluated now Even further step tested to be OK: ```nimrod proc semConstExpr(c: PContext, n: PNode): PNode = result = semAndEvalConstExpr(c, n) ```
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/semexprs.nim | 2 | ||||
-rwxr-xr-x | compiler/semstmts.nim | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 1b4f778a8..5f4c7749a 100755 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -747,7 +747,7 @@ proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode = checkSonsLen(n, 2) n.sons[0] = makeDeref(n.sons[0]) # [] operator for tuples requires constant expression: - n.sons[1] = semConstExpr(c, n.sons[1]) + n.sons[1] = semAndEvalConstExpr(c, n.sons[1]) if skipTypes(n.sons[1].typ, {tyGenericInst, tyRange, tyOrdinal}).kind in {tyInt..tyInt64}: var idx = getOrdValue(n.sons[1]) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index ce870a3ad..decc8a2d7 100755 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -19,7 +19,7 @@ proc semWhen(c: PContext, n: PNode): PNode = case it.kind of nkElifBranch: checkSonsLen(it, 2) - var e = semConstBoolExpr(c, it.sons[0]) + var e = semAndEvalConstExpr(c, it.sons[0]) if (e.kind != nkIntLit): InternalError(n.info, "semWhen") if (e.intVal != 0) and (result == nil): result = semStmt(c, it.sons[1]) # do not open a new scope! |