diff options
-rw-r--r-- | compiler/semmagic.nim | 2 | ||||
-rw-r--r-- | tests/arc/tarcmisc.nim | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim index 5cd7b28b0..cffd58b92 100644 --- a/compiler/semmagic.nim +++ b/compiler/semmagic.nim @@ -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})) diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim index b53d49df8..8d857921e 100644 --- a/tests/arc/tarcmisc.nim +++ b/tests/arc/tarcmisc.nim @@ -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) \ No newline at end of file +text_parser(xml2) + +# bug #15599 +type + PixelBuffer = ref object + +proc newPixelBuffer(): PixelBuffer = + new(result) do (buffer: PixelBuffer): + echo "ok" + +discard newPixelBuffer() + |