Reset exprs before return by arg. Fixes #5098 (#5191)

This commit is contained in:
Brandon Pickering 2017-01-10 21:24:31 -08:00 • committed by Andreas Rumpf
commit da1293c405
2 changed files with 28 additions and 2 deletions

View file

@ -0,0 +1,26 @@
discard """
output: '''nil
nil
nil'''
"""
type Bar = object
s1, s2: string
proc initBar(): Bar = discard
var a: array[5, Bar]
a[0].s1 = "hey"
a[0] = initBar()
echo a[0].s1
type Foo = object
b: Bar
var f: Foo
f.b.s1 = "hi"
f.b = initBar()
echo f.b.s1
var ad = addr f.b
ad[] = initBar()
echo ad[].s1