From 424e87fd0917704155d2e7a94f69435eb50d6037 Mon Sep 17 00:00:00 2001 From: Yuriy Glukhov Date: Thu, 28 Jul 2022 12:43:41 +0200 Subject: [PATCH] Fixed noinit pragma for closure variables (#20101) --- compiler/ccgstmts.nim | 2 +- compiler/lowerings.nim | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index 3ecf68402..0d17031df 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -405,7 +405,7 @@ proc genClosureVar(p: BProc, a: PNode) = genLineDir(p, a) if immediateAsgn: loadInto(p, a[0], a[2], v) - else: + elif sfNoInit notin a[0][1].sym.flags: constructLoc(p, v) proc genVarStmt(p: BProc, n: PNode) = diff --git a/compiler/lowerings.nim b/compiler/lowerings.nim index de2f678d7..fc66fc9fa 100644 --- a/compiler/lowerings.nim +++ b/compiler/lowerings.nim @@ -241,7 +241,8 @@ proc addField*(obj: PType; s: PSym; cache: IdentCache; idgen: IdGenerator): PSym assert t.kind != tyTyped propagateToOwner(obj, t) field.position = obj.n.len - field.flags = s.flags * {sfCursor} + # sfNoInit flag for skField is used in closureiterator codegen + field.flags = s.flags * {sfCursor, sfNoInit} obj.n.add newSymNode(field) fieldCheck() result = field