* Fix #14568 * Add testcase * Fix bogus test * Adapt other failing tests * Declarations are always first writes
This commit is contained in:
parent
754a196d47
commit
52841dba09
3 changed files with 49 additions and 25 deletions
|
|
@ -36,6 +36,10 @@ fff
|
|||
mmm
|
||||
sink me (sink)
|
||||
assign me (not sink)
|
||||
sink me (not sink)
|
||||
sinked and not optimized to a bitcopy
|
||||
sinked and not optimized to a bitcopy
|
||||
sinked and not optimized to a bitcopy
|
||||
'''
|
||||
"""
|
||||
|
||||
|
|
@ -273,10 +277,10 @@ type ME = object
|
|||
who: string
|
||||
|
||||
proc `=`(x: var ME, y: ME) =
|
||||
if x.who.len > 0: echo "assign ",x.who
|
||||
if y.who.len > 0: echo "assign ",y.who
|
||||
|
||||
proc `=sink`(x: var ME, y: ME) =
|
||||
if x.who.len > 0: echo "sink ",x.who
|
||||
if y.who.len > 0: echo "sink ",y.who
|
||||
|
||||
var dump: ME
|
||||
template use(x) = dump = x
|
||||
|
|
@ -302,3 +306,22 @@ proc shouldNotSink() =
|
|||
use(x) # Not ok without the '[else]'
|
||||
|
||||
shouldNotSink()
|
||||
|
||||
# bug #14568
|
||||
import os
|
||||
|
||||
type O2 = object
|
||||
s: seq[int]
|
||||
|
||||
proc `=sink`(dest: var O2, src: O2) =
|
||||
echo "sinked and not optimized to a bitcopy"
|
||||
|
||||
var testSeq: O2
|
||||
|
||||
proc Update(): void =
|
||||
# testSeq.add(0) # uncommenting this line fixes the leak
|
||||
testSeq = O2(s: @[])
|
||||
testSeq.s.add(0)
|
||||
|
||||
for i in 1..3:
|
||||
Update()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue