@@ -264,17 +264,6 @@ when not defined(gcDestructors):
264264 # # **Note**: The `finalizer` refers to the type `T`, not to the object!
265265 # # This means that for each object of type `T` the finalizer will be called!
266266
267- when defined (nimV2):
268- proc reset * [T](obj: var T) {.magic : " Destroy" , noSideEffect .}
269- # # Old runtime target: Resets an object `obj` to its initial (binary zero) value.
270- # #
271- # # New runtime target: An alias for `=destroy`.
272- else :
273- proc reset * [T](obj: var T) {.magic : " Reset" , noSideEffect .}
274- # # Old runtime target: Resets an object `obj` to its initial (binary zero) value.
275- # #
276- # # New runtime target: An alias for `=destroy`.
277-
278267proc wasMoved * [T](obj: var T) {.magic : " WasMoved" , noSideEffect .} =
279268 # # Resets an object `obj` to its initial (binary zero) value to signify
280269 # # it was "moved" and to signify its destructor should do nothing and
@@ -1825,6 +1814,15 @@ when defined(nimHasDefault):
18251814 proc default * (T: typedesc ): T {.magic : " Default" , noSideEffect .}
18261815 # # returns the default value of the type ``T``.
18271816
1817+ proc reset * [T](obj: var T) {.noSideEffect .} =
1818+ # # Resets an object `obj` to its default value.
1819+ obj = default (typeof (obj))
1820+ else :
1821+ when defined (nimV2):
1822+ proc reset * [T](obj: var T) {.magic : " Destroy" , noSideEffect .}
1823+ else :
1824+ proc reset * [T](obj: var T) {.magic : " Reset" , noSideEffect .}
1825+
18281826proc setLen * [T](s: var seq [T], newlen: Natural ) {.
18291827 magic : " SetLengthSeq" , noSideEffect .}
18301828 # # Sets the length of seq `s` to `newlen`. ``T`` may be any sequence type.
0 commit comments