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) ```
This commit is contained in:
parent
9b95ca407d
commit
a28cf4e9cb
2 changed files with 2 additions and 2 deletions
|
|
@ -747,7 +747,7 @@ proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
checkSonsLen(n, 2)
|
checkSonsLen(n, 2)
|
||||||
n.sons[0] = makeDeref(n.sons[0])
|
n.sons[0] = makeDeref(n.sons[0])
|
||||||
# [] operator for tuples requires constant expression:
|
# [] 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
|
if skipTypes(n.sons[1].typ, {tyGenericInst, tyRange, tyOrdinal}).kind in
|
||||||
{tyInt..tyInt64}:
|
{tyInt..tyInt64}:
|
||||||
var idx = getOrdValue(n.sons[1])
|
var idx = getOrdValue(n.sons[1])
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ proc semWhen(c: PContext, n: PNode): PNode =
|
||||||
case it.kind
|
case it.kind
|
||||||
of nkElifBranch:
|
of nkElifBranch:
|
||||||
checkSonsLen(it, 2)
|
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.kind != nkIntLit): InternalError(n.info, "semWhen")
|
||||||
if (e.intVal != 0) and (result == nil):
|
if (e.intVal != 0) and (result == nil):
|
||||||
result = semStmt(c, it.sons[1]) # do not open a new scope!
|
result = semStmt(c, it.sons[1]) # do not open a new scope!
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue