* Fix #15599

* Add test

(cherry picked from commit 66cd9c2e57)
This commit is contained in:
Clyybber
2020-10-16 18:03:01 +02:00
committed by narimiran
parent b3c77bb982
commit d86d7c9fe1
2 changed files with 14 additions and 2 deletions

View File

@@ -527,7 +527,7 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode,
if n[^1].kind == nkSym and n[^1].sym.kind notin {skProc, skFunc}:
localError(c.config, n.info, "finalizer must be a direct reference to a proc")
elif optTinyRtti in c.config.globalOptions:
let fin = if n[^1].kind == nkLambda: n[^1][namePos].sym
let fin = if n[^1].kind in {nkLambda, nkDo}: n[^1][namePos].sym
else: n[^1].sym
# check if we converted this finalizer into a destructor already:
let t = whereToBindTypeHook(c, fin.typ[1].skipTypes(abstractInst+{tyRef}))

View File

@@ -26,6 +26,7 @@ new line after - @['a']
finalizer
aaaaa
hello
ok
closed
destroying variable: 20
destroying variable: 10
@@ -377,4 +378,15 @@ proc text_parser(xml: var XmlParser) =
doAssert(test_passed)
text_parser(xml)
text_parser(xml2)
text_parser(xml2)
# bug #15599
type
PixelBuffer = ref object
proc newPixelBuffer(): PixelBuffer =
new(result) do (buffer: PixelBuffer):
echo "ok"
discard newPixelBuffer()