mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
adds T destructor for refs (#22147)
* adds T destructor for refs * add `newRefdestructor` * adds ref overload for destructors * fixes config
This commit is contained in:
@@ -1068,7 +1068,12 @@ proc symPrototype(g: ModuleGraph; typ: PType; owner: PSym; kind: TTypeAttachedOp
|
||||
let dest = newSym(skParam, getIdent(g.cache, "dest"), idgen, result, info)
|
||||
let src = newSym(skParam, getIdent(g.cache, if kind == attachedTrace: "env" else: "src"),
|
||||
idgen, result, info)
|
||||
dest.typ = makeVarType(typ.owner, typ, idgen)
|
||||
|
||||
if kind == attachedDestructor and typ.kind == tyRef:
|
||||
dest.typ = typ
|
||||
else:
|
||||
dest.typ = makeVarType(typ.owner, typ, idgen)
|
||||
|
||||
if kind == attachedTrace:
|
||||
src.typ = getSysType(g, info, tyPointer)
|
||||
else:
|
||||
|
||||
@@ -365,6 +365,10 @@ proc arrGet[I: Ordinal;T](a: T; i: I): T {.
|
||||
proc arrPut[I: Ordinal;T,S](a: T; i: I;
|
||||
x: S) {.noSideEffect, magic: "ArrPut".}
|
||||
|
||||
when defined(nimAllowNonVarDestructor):
|
||||
proc `=destroy`*[T](x: ref T) {.inline, magic: "Destroy".} =
|
||||
discard
|
||||
|
||||
proc `=destroy`*[T](x: var T) {.inline, magic: "Destroy".} =
|
||||
## Generic `destructor`:idx: implementation that can be overridden.
|
||||
discard
|
||||
|
||||
@@ -43,3 +43,4 @@ switch("define", "nimPreviewRangeDefault")
|
||||
|
||||
switch("warningAserror", "UnnamedBreak")
|
||||
switch("legacy", "verboseTypeMismatch")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user