mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
make reset use the =destroy and wasMoved pair (#21821)
* make reset use the `=destroy` and `waMoved` pair * fixes a space * fixes `shrink` instead * tiny fix * fixes vm * suppress the annotations since it breaks some important packages
This commit is contained in:
@@ -906,7 +906,15 @@ proc default*[T](_: typedesc[T]): T {.magic: "Default", noSideEffect.} =
|
||||
|
||||
proc reset*[T](obj: var T) {.noSideEffect.} =
|
||||
## Resets an object `obj` to its default value.
|
||||
obj = default(typeof(obj))
|
||||
when nimvm:
|
||||
obj = default(typeof(obj))
|
||||
else:
|
||||
when defined(gcDestructors):
|
||||
{.cast(noSideEffect), cast(raises: []), cast(tags: []).}:
|
||||
`=destroy`(obj)
|
||||
wasMoved(obj)
|
||||
else:
|
||||
obj = default(typeof(obj))
|
||||
|
||||
proc setLen*[T](s: var seq[T], newlen: Natural) {.
|
||||
magic: "SetLengthSeq", noSideEffect.}
|
||||
|
||||
Reference in New Issue
Block a user