Skip to content

Commit

Permalink
assign: avoid clearing unrelated fields in variant objects (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck committed Sep 22, 2023
1 parent f3a9bb4 commit 99fe817
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Nim
Submodule Nim updated 1 files
+3 −0 compiler/aliases.nim
9 changes: 5 additions & 4 deletions nlvm/llgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3830,9 +3830,11 @@ proc genAssignFields(
for child in n:
g.genAssignFields(mapper, child, ty, dest, src, shallow)
of nkRecCase:
block: # Reset the destination which releases all held memory
var resetMapper = mapper
g.genResetFields(resetMapper, n, ty, LLValue(v: dest))
block: # Reset kind-specific fields of the destination
# TODO: we could skip this if tag is unchanged
var mapper = mapper
withRecCase(n, ty, dest):
g.genResetFields(recMapper, branch.lastSon, branchTy, LLValue(v: storeGEP))

block: # Set field discriminator and copy fields
withRecCase(n, ty, src):
Expand Down Expand Up @@ -7668,7 +7670,6 @@ proc genNodeObjConstr(g: LLGen, n: PNode, load: bool, dest: LLValue): LLValue =
else:
g.callReset(typ, dest)
dest

for i in 1 ..< n.len:
let
s = n[i]
Expand Down

0 comments on commit 99fe817

Please sign in to comment.