* Fix #15599

* Add test
This commit is contained in:
Clyybber 2020-10-16 18:03:01 +02:00 • committed by GitHub
commit 66cd9c2e57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
@ -378,3 +379,14 @@ proc text_parser(xml: var XmlParser) =
text_parser(xml)
text_parser(xml2)
# bug #15599
type
PixelBuffer = ref object
proc newPixelBuffer(): PixelBuffer =
new(result) do (buffer: PixelBuffer):
echo "ok"
discard newPixelBuffer()