mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-24 23:51:41 +00:00
Revert "make explicit copy and hook calls keep their symbol (#25731)"
This reverts commit a35614e539.
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
discard """
|
||||
output: '''
|
||||
246
|
||||
246
|
||||
'''
|
||||
"""
|
||||
|
||||
# issue #25730
|
||||
|
||||
type
|
||||
Inner[T] = object
|
||||
x: T
|
||||
Foo[T] = object
|
||||
inner: Inner[T]
|
||||
Bar[T] = object
|
||||
foo: Foo[T]
|
||||
|
||||
proc `=sink`[T](a: var Inner[T], b: Inner[T]) {.nodestroy.} =
|
||||
a.x = b.x * 2
|
||||
|
||||
proc `=copy`[T](a: var Inner[T], b: Inner[T]) {.nodestroy.} =
|
||||
a.x = b.x * 2
|
||||
|
||||
when true:
|
||||
proc `=sink`[T](a: var Bar[T], b: Bar[T]) {.nodestroy.} =
|
||||
`=sink`(a.foo, b.foo)
|
||||
|
||||
proc `=copy`[T](a: var Bar[T], b: Bar[T]) {.nodestroy.} =
|
||||
`=copy`(a.foo, b.foo)
|
||||
|
||||
proc useSink() =
|
||||
let a = Bar[int](foo: Foo[int](inner: Inner[int](x: 123)))
|
||||
var b: Bar[int]
|
||||
`=sink`(b, a)
|
||||
echo b.foo.inner.x
|
||||
|
||||
useSink()
|
||||
|
||||
proc useCopy() =
|
||||
let a = Bar[int](foo: Foo[int](inner: Inner[int](x: 123)))
|
||||
var b: Bar[int]
|
||||
`=copy`(b, a)
|
||||
echo b.foo.inner.x
|
||||
|
||||
useCopy()
|
||||
Reference in New Issue
Block a user