fixes #2134
This commit is contained in:
parent
aef7be2e79
commit
77406dd59c
2 changed files with 34 additions and 1 deletions
|
|
@ -156,7 +156,7 @@ proc semForFields(c: PContext, n: PNode, m: TMagic): PNode =
|
||||||
dec(c.p.nestedLoopCounter)
|
dec(c.p.nestedLoopCounter)
|
||||||
# for TR macros this 'while true: ...; break' loop is pretty bad, so
|
# for TR macros this 'while true: ...; break' loop is pretty bad, so
|
||||||
# we avoid it now if we can:
|
# we avoid it now if we can:
|
||||||
if hasSonWith(stmts, nkBreakStmt):
|
if containsNode(stmts, {nkBreakStmt}):
|
||||||
var b = newNodeI(nkBreakStmt, n.info)
|
var b = newNodeI(nkBreakStmt, n.info)
|
||||||
b.add(ast.emptyNode)
|
b.add(ast.emptyNode)
|
||||||
stmts.add(b)
|
stmts.add(b)
|
||||||
|
|
|
||||||
33
tests/fields/tfields_with_break.nim
Normal file
33
tests/fields/tfields_with_break.nim
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
discard """
|
||||||
|
output: '''(one: 1, two: 2, three: 3)
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
(one: 4, two: 5, three: 6)
|
||||||
|
4
|
||||||
|
(one: 7, two: 8, three: 9)
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #2134
|
||||||
|
type
|
||||||
|
TestType = object
|
||||||
|
one: int
|
||||||
|
two: int
|
||||||
|
three: int
|
||||||
|
|
||||||
|
var
|
||||||
|
ab = TestType(one:1, two:2, three:3)
|
||||||
|
ac = TestType(one:4, two:5, three:6)
|
||||||
|
ad = TestType(one:7, two:8, three:9)
|
||||||
|
tstSeq = [ab, ac, ad]
|
||||||
|
|
||||||
|
for tstElement in mitems(tstSeq):
|
||||||
|
echo tstElement
|
||||||
|
for tstField in fields(tstElement):
|
||||||
|
#for tstField in [1,2,4,6]:
|
||||||
|
echo tstField
|
||||||
|
if tstField == 4:
|
||||||
|
break
|
||||||
Loading…
Add table
Add a link
Reference in a new issue