From e6c963259ce38e9467f45839e9ee433b00dabaa4 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 1 Jul 2019 13:12:04 +0200 Subject: [PATCH] fixes #11617 (cherry picked from commit bd55c862a6ed8ee33caab2e93e1ad7f9e5bd85a5) --- compiler/semobjconstr.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/semobjconstr.nim b/compiler/semobjconstr.nim index c9216cc512..1130abef3a 100644 --- a/compiler/semobjconstr.nim +++ b/compiler/semobjconstr.nim @@ -352,6 +352,9 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode = t = skipTypes(t.sons[0], {tyGenericInst, tyAlias, tySink, tyOwned}) if optNimV2 in c.config.globalOptions: result.typ = makeVarType(c, result.typ, tyOwned) + # we have to watch out, there are also 'owned proc' types that can be used + # multiple times as long as they don't have closures. + result.typ.flags.incl tfHasOwned if t.kind != tyObject: localError(c.config, n.info, errGenerated, "object constructor needs an object type") return