* fix #14217

Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
cooldome 2020-05-05 06:26:32 +01:00 • committed by GitHub
commit eefada8a88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 3 deletions

View file

@ -32,3 +32,29 @@ proc test1() =
echo "test1 OK"
test1()
#------------------------------------------------------------------------------
# issue #14217
type
MyObject = object
p: ptr int
proc `=destroy`(x: var MyObject) =
if x.p != nil:
deallocShared(x.p)
proc `=`(x: var MyObject, y: MyObject) {.error.}
proc newMyObject(i: int): MyObject =
result.p = create(int)
result.p[] = i
proc test: seq[MyObject] =
for i in 0..3:
let x = newMyObject(i)
result.add x
var x = test()
for i in 0..3:
doAssert(x[i].p[] == i)