diff options
author | Yuriy Glukhov <yglukhov@users.noreply.github.com> | 2022-07-28 12:43:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-28 18:43:41 +0800 |
commit | 424e87fd0917704155d2e7a94f69435eb50d6037 (patch) | |
tree | 0e41060c18be138cc53e3a3becbb23d0f5f31b07 /compiler | |
parent | 8ef509b85bc53a452ee44ee4757fd072a6d77e8f (diff) | |
download | Nim-424e87fd0917704155d2e7a94f69435eb50d6037.tar.gz |
Fixed noinit pragma for closure variables (#20101)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgstmts.nim | 2 | ||||
-rw-r--r-- | 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 |