From 881d1dfdb6faf494ccb1b021470a22aafe6cc90d Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 26 Feb 2025 00:05:59 +0800 Subject: [PATCH] undeprecates `var T` destructors (#24716) Both cases are now valid. Though, it could be problematic to mix two cases together as built-in types have non var T destructors (cherry picked from commit 93fb219f1091ff4859e9eda3b138cbec3ba81ff3) --- compiler/semstmts.nim | 3 --- doc/destructors.md | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 9295b873c8..1ca9ebefff 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -2158,9 +2158,6 @@ proc bindTypeHook(c: PContext; s: PSym; n: PNode; op: TTypeAttachedOp) = elif obj.kind == tyGenericInvocation: obj = obj.genericHead else: break if obj.kind in {tyObject, tyDistinct, tySequence, tyString}: - if op == attachedDestructor and t.firstParamType.kind == tyVar and - c.config.selectedGC in {gcArc, gcAtomicArc, gcOrc}: - message(c.config, n.info, warnDeprecated, "A custom '=destroy' hook which takes a 'var T' parameter is deprecated; it should take a 'T' parameter") obj = canonType(c, obj) let ao = getAttachedOp(c.graph, obj, op) if ao == s: diff --git a/doc/destructors.md b/doc/destructors.md index e192fd362c..5344dfedea 100644 --- a/doc/destructors.md +++ b/doc/destructors.md @@ -129,7 +129,8 @@ other associated resources. Variables are destroyed via this hook when they go out of scope or when the routine they were declared in is about to return. -A `=destroy` hook is allowed to have a parameter of a `var T` or `T` type. Taking a `var T` type is deprecated. The prototype of this hook for a type `T` needs to be: +A `=destroy` hook is allowed to have a parameter of a `var T` or `T` type. +The prototype of this hook for a type `T` needs to be: ```nim proc `=destroy`(x: T)