fixes #15101 [backport] (#15171)

This commit is contained in:
Andreas Rumpf 2020-08-08 23:08:34 +02:00 • committed by GitHub
commit 2a8bf470af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,7 +23,7 @@ proc instFieldLoopBody(c: TFieldInstCtx, n: PNode, forLoop: PNode): PNode =
result = newNode(nkEmpty) result = newNode(nkEmpty)
return return
case n.kind case n.kind
of nkEmpty..pred(nkIdent), succ(nkSym)..nkNilLit: result = n of nkEmpty..pred(nkIdent), succ(nkSym)..nkNilLit: result = copyNode(n)
of nkIdent, nkSym: of nkIdent, nkSym:
result = n result = n
let ident = considerQuotedIdent(c.c, n) let ident = considerQuotedIdent(c.c, n)
@ -52,8 +52,7 @@ proc instFieldLoopBody(c: TFieldInstCtx, n: PNode, forLoop: PNode): PNode =
if n.kind == nkContinueStmt: if n.kind == nkContinueStmt:
localError(c.c.config, n.info, localError(c.c.config, n.info,
"'continue' not supported in a 'fields' loop") "'continue' not supported in a 'fields' loop")
result = copyNode(n) result = shallowCopy(n)
newSons(result, n.len)
for i in 0..<n.len: for i in 0..<n.len:
result[i] = instFieldLoopBody(c, n[i], forLoop) result[i] = instFieldLoopBody(c, n[i], forLoop)