From f18e4c4050cb59cf828372f89c01d9e80f6516c5 Mon Sep 17 00:00:00 2001 From: Bung Date: Sun, 6 Aug 2023 19:07:01 +0800 Subject: [PATCH] fix set op related to {sfGlobal, sfPure} (#22393) --- compiler/hlo.nim | 2 +- compiler/injectdestructors.nim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/hlo.nim b/compiler/hlo.nim index 1aab9d5fe9..2e1652f09d 100644 --- a/compiler/hlo.nim +++ b/compiler/hlo.nim @@ -73,7 +73,7 @@ proc hlo(c: PContext, n: PNode): PNode = else: if n.kind in {nkFastAsgn, nkAsgn, nkSinkAsgn, nkIdentDefs, nkVarTuple} and n[0].kind == nkSym and - {sfGlobal, sfPure} * n[0].sym.flags == {sfGlobal, sfPure}: + {sfGlobal, sfPure} <= n[0].sym.flags: # do not optimize 'var g {.global} = re(...)' again! return n result = applyPatterns(c, n) diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 15f375d28f..4463d1d694 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -1154,7 +1154,7 @@ proc moveOrCopy(dest, ri: PNode; c: var Con; s: var Scope, flags: set[MoveOrCopy result = newTree(nkStmtList, snk, c.genWasMoved(ri)) elif ri.sym.kind != skParam and ri.sym.owner == c.owner and isLastRead(ri, c, s) and canBeMoved(c, dest.typ) and not isCursor(ri) and - {sfGlobal, sfPure} <= ri.sym.flags == false: + not ({sfGlobal, sfPure} <= ri.sym.flags): # Rule 3: `=sink`(x, z); wasMoved(z) let snk = c.genSink(s, dest, ri, flags) result = newTree(nkStmtList, snk, c.genWasMoved(ri))