summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2023-08-06 19:07:01 +0800
committerGitHub <noreply@github.com>2023-08-06 19:07:01 +0800
commitf18e4c4050cb59cf828372f89c01d9e80f6516c5 (patch)
tree0e488df1cb32e564cac08b028ea4b41d746669e6
parent95c751a9e4d42eb61917684339406d1ff07a4225 (diff)
downloadNim-f18e4c4050cb59cf828372f89c01d9e80f6516c5.tar.gz
fix set op related to {sfGlobal, sfPure} (#22393)
-rw-r--r--compiler/hlo.nim2
-rw-r--r--compiler/injectdestructors.nim2
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/hlo.nim b/compiler/hlo.nim
index 1aab9d5fe..2e1652f09 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 15f375d28..4463d1d69 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))