fixes #6992
This commit is contained in:
parent
f9b742c72a
commit
b35ee82c48
2 changed files with 19 additions and 1 deletions
|
|
@ -692,6 +692,12 @@ proc implicitIterator(c: PContext, it: string, arg: PNode): PNode =
|
||||||
result.add arg
|
result.add arg
|
||||||
result = semExprNoDeref(c, result, {efWantIterator})
|
result = semExprNoDeref(c, result, {efWantIterator})
|
||||||
|
|
||||||
|
proc isTrivalStmtExpr(n: PNode): bool =
|
||||||
|
for i in 0 .. n.len-2:
|
||||||
|
if n[i].kind notin {nkEmpty, nkCommentStmt}:
|
||||||
|
return false
|
||||||
|
result = true
|
||||||
|
|
||||||
proc semFor(c: PContext, n: PNode): PNode =
|
proc semFor(c: PContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
checkMinSonsLen(n, 3)
|
checkMinSonsLen(n, 3)
|
||||||
|
|
@ -699,6 +705,9 @@ proc semFor(c: PContext, n: PNode): PNode =
|
||||||
openScope(c)
|
openScope(c)
|
||||||
n.sons[length-2] = semExprNoDeref(c, n.sons[length-2], {efWantIterator})
|
n.sons[length-2] = semExprNoDeref(c, n.sons[length-2], {efWantIterator})
|
||||||
var call = n.sons[length-2]
|
var call = n.sons[length-2]
|
||||||
|
if call.kind == nkStmtListExpr and isTrivalStmtExpr(call):
|
||||||
|
call = call.lastSon
|
||||||
|
n.sons[length-2] = call
|
||||||
let isCallExpr = call.kind in nkCallKinds
|
let isCallExpr = call.kind in nkCallKinds
|
||||||
if isCallExpr and call[0].kind == nkSym and
|
if isCallExpr and call[0].kind == nkSym and
|
||||||
call[0].sym.magic in {mFields, mFieldPairs, mOmpParFor}:
|
call[0].sym.magic in {mFields, mFieldPairs, mOmpParFor}:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,12 @@ discard """
|
||||||
output: '''true
|
output: '''true
|
||||||
3
|
3
|
||||||
4
|
4
|
||||||
5'''
|
5
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4'''
|
||||||
cmd: "nim $target --gc:none --hints:on --warnings:off $options $file"
|
cmd: "nim $target --gc:none --hints:on --warnings:off $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -55,3 +60,7 @@ echo "true"
|
||||||
# bug #1560
|
# bug #1560
|
||||||
for i in @[3, 4, 5]:
|
for i in @[3, 4, 5]:
|
||||||
echo($i)
|
echo($i)
|
||||||
|
|
||||||
|
# bug #6992
|
||||||
|
for i in 0 ..< 5u32:
|
||||||
|
echo i
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue