Skip to content

Commit 27131d4

Browse files
committed
checkpoint
1 parent 934943d commit 27131d4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compiler/injectdestructors.nim

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,19 @@ proc checkForErrorPragma(c: Con; t: PType; ri: PNode; opname: string; inferredFr
216216
#m.add renderTree(c.body, {renderIds})
217217
localError(c.graph.config, ri.info, errGenerated, m)
218218

219-
proc makePtrType(c: var Con, baseType: PType): PType =
220-
result = newType(tyPtr, c.idgen, c.owner)
221-
addSonSkipIntLit(result, baseType, c.idgen)
219+
proc genAddr(c: var Con; x: PNode): PNode =
220+
if x.kind == nkHiddenDeref:
221+
result = x[0]
222+
else:
223+
result = newNodeIT(nkHiddenAddr, x.info, makeVarType(x.typ.owner, x.typ, c.idgen))
224+
result.add x
222225

223226
proc genOp(c: var Con; op: PSym; dest: PNode): PNode =
224227
var addrExp: PNode
225228
if op.typ != nil and op.typ.signatureLen > 1 and op.typ.firstParamType.kind != tyVar:
226229
addrExp = dest
227230
else:
228-
addrExp = newNodeIT(nkHiddenAddr, dest.info, makePtrType(c, dest.typ))
229-
addrExp.add(dest)
231+
addrExp = genAddr(c, dest)
230232
result = newTree(nkCall, newSymNode(op), addrExp)
231233

232234
proc genOp(c: var Con; t: PType; kind: TTypeAttachedOp; dest, ri: PNode): PNode =

0 commit comments

Comments
 (0)