From 42020a2331901396c1bcf8da0a59562b0b1068f2 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) (cherry picked from commit 424e87fd0917704155d2e7a94f69435eb50d6037) --- 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 b0638b6691..d1eed4c324 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 ba778fe34b..7f0f1ca18b 100644 --- a/compiler/lowerings.nim +++ b/compiler/lowerings.nim @@ -238,7 +238,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