* fix #15609

* fix test
This commit is contained in:
cooldome 2020-11-05 22:29:05 +00:00 • committed by GitHub
commit fa5f225efc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 10 deletions

View file

@ -70,6 +70,9 @@ king
hi
try
bye
()
()
()
'''
"""
@ -524,3 +527,33 @@ proc getScope2(): string =
"else"
echo getScope2()
#--------------------------------------------------------------------
#bug #15609
type
Wrapper = object
discard
proc newWrapper(): ref Wrapper =
new(result)
result
proc newWrapper2(a: int): ref Wrapper =
new(result)
if a > 0:
result
else:
new(Wrapper)
let w1 = newWrapper()
echo $w1[]
let w2 = newWrapper2(1)
echo $w2[]
let w3 = newWrapper2(-1)
echo $w3[]