Skip to content

Commit

Permalink
liftdestructors: fix the call AST construction
Browse files Browse the repository at this point in the history
There are two places where hook calls are manually constructed, both
which didn't wrap the first argument in a `nkHiddenAddr` tree.
  • Loading branch information
zerbina committed Dec 26, 2024
1 parent 4c8d983 commit b6cbe85
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions compiler/sem/liftdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,7 @@ proc getCycleParam(c: TLiftCtx): PNode =
proc newHookCall(c: var TLiftCtx; op: PSym; x, y: PNode): PNode =
#if sfError in op.flags:
# localReport(c.config, x.info, "usage of '$1' is a user-defined error" % op.name.s)
result = newNodeI(nkCall, x.info)
result.add newSymNode(op)
if op.typ.sons[1].kind == tyVar:
result.add genAddr(c, x)
else:
result.add x
result = newTreeI(nkCall, x.info, newSymNode(op), genAddr(c, x))
if y != nil:
result.add y
if op.typ.len == 4:
Expand Down Expand Up @@ -885,7 +880,8 @@ proc produceSym(g: ModuleGraph; c: PContext; typ: PType; kind: TTypeAttachedOp;
if kind == attachedSink and destructorOverriden(g, typ):
## compiler can use a combination of `=destroy` and memCopy for sink op
dest.flags.incl sfCursor
result.ast[bodyPos].add newOpCall(a, getAttachedOp(g, typ, attachedDestructor), d[0])
result.ast[bodyPos].add newOpCall(a, getAttachedOp(g, typ, attachedDestructor),
genAddr(a, d))
result.ast[bodyPos].add newAsgnStmt(d, src)
else:
let (tk, baseTyp) =
Expand Down

0 comments on commit b6cbe85

Please sign in to comment.