Skip to content

Commit

Permalink
fix set op related to {sfGlobal, sfPure}
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 committed Aug 6, 2023
1 parent 95c751a commit 16eda65
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compiler/hlo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compiler/injectdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion compiler/semstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ proc semVarMacroPragma(c: PContext, a: PNode, n: PNode): PNode =

template isLocalSym(sym: PSym): bool =
sym.kind in {skVar, skLet, skParam} and not
({sfGlobal, sfPure} * sym.flags != {} or
({sfGlobal, sfPure} <= sym.flags or
sym.typ.kind == tyTypeDesc or
sfCompileTime in sym.flags) or
sym.kind in {skProc, skFunc, skIterator} and
Expand Down

0 comments on commit 16eda65

Please sign in to comment.