fixes a collect() bug reported on the forum (#15156) [backport:1.2]

(cherry picked from commit 64aec6eb85)
This commit is contained in:
Andreas Rumpf
2020-08-04 12:45:15 +02:00
committed by narimiran
parent 0ddf7153b8
commit 67d729aa2e
2 changed files with 11 additions and 1 deletions

View File

@@ -161,7 +161,7 @@ proc semIf(c: PContext, n: PNode; flags: TExprFlags): PNode =
if it.len == 2:
openScope(c)
it[0] = forceBool(c, semExprWithType(c, it[0]))
it[1] = semExprBranch(c, it[1])
it[1] = semExprBranch(c, it[1], flags)
typ = commonType(typ, it[1])
closeScope(c)
elif it.len == 1:

View File

@@ -369,3 +369,13 @@ when isMainModule:
of "bird": "word"
else: d
assert z == @["word", "word"]
proc tforum =
let ans = collect(newSeq):
for y in 0..10:
if y mod 5 == 2:
for x in 0..y:
x
tforum()