mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
fixes #22286
ref https://forum.nim-lang.org/t/10642
For backwards compatibilities, we might need to keep the changes under a
preview compiler flag. Let's see how many packags it break.
**TODO** in the following PRs
- [ ] Turn the `var T` destructors warning into an error with
`nimPreviewNonVarDestructor`
---------
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
(cherry picked from commit 379299a5ac)
This commit is contained in:
@@ -368,19 +368,24 @@ proc arrPut[I: Ordinal;T,S](a: T; i: I;
|
||||
const arcLikeMem = defined(gcArc) or defined(gcAtomicArc) or defined(gcOrc)
|
||||
|
||||
|
||||
when defined(nimAllowNonVarDestructor) and arcLikeMem:
|
||||
proc `=destroy`*(x: string) {.inline, magic: "Destroy".} =
|
||||
when defined(nimAllowNonVarDestructor) and arcLikeMem and defined(nimPreviewNonVarDestructor):
|
||||
proc `=destroy`*[T](x: T) {.inline, magic: "Destroy".} =
|
||||
## Generic `destructor`:idx: implementation that can be overridden.
|
||||
discard
|
||||
else:
|
||||
proc `=destroy`*[T](x: var T) {.inline, magic: "Destroy".} =
|
||||
## Generic `destructor`:idx: implementation that can be overridden.
|
||||
discard
|
||||
|
||||
proc `=destroy`*[T](x: seq[T]) {.inline, magic: "Destroy".} =
|
||||
discard
|
||||
when defined(nimAllowNonVarDestructor) and arcLikeMem:
|
||||
proc `=destroy`*(x: string) {.inline, magic: "Destroy".} =
|
||||
discard
|
||||
|
||||
proc `=destroy`*[T](x: ref T) {.inline, magic: "Destroy".} =
|
||||
discard
|
||||
proc `=destroy`*[T](x: seq[T]) {.inline, magic: "Destroy".} =
|
||||
discard
|
||||
|
||||
proc `=destroy`*[T](x: var T) {.inline, magic: "Destroy".} =
|
||||
## Generic `destructor`:idx: implementation that can be overridden.
|
||||
discard
|
||||
proc `=destroy`*[T](x: ref T) {.inline, magic: "Destroy".} =
|
||||
discard
|
||||
|
||||
when defined(nimHasDup):
|
||||
proc `=dup`*[T](x: T): T {.inline, magic: "Dup".} =
|
||||
|
||||
Reference in New Issue
Block a user