special typing rules for owned pointers

This commit is contained in:
Andreas Rumpf 2019-03-03 19:00:05 +01:00
commit a6d49c3a81
6 changed files with 52 additions and 19 deletions

View file

@ -263,8 +263,11 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
localError(c.config, n.info, errGenerated, "object constructor needs an object type")
return
t = skipTypes(t, {tyGenericInst, tyAlias, tySink})
if t.kind == tyRef: t = skipTypes(t.sons[0], {tyGenericInst, tyAlias, tySink})
t = skipTypes(t, {tyGenericInst, tyAlias, tySink, tyOwned})
if t.kind == tyRef:
t = skipTypes(t.sons[0], {tyGenericInst, tyAlias, tySink, tyOwned})
if optNimV2 in c.config.globalOptions:
result.typ = makeVarType(c, result.typ, tyOwned)
if t.kind != tyObject:
localError(c.config, n.info, errGenerated, "object constructor needs an object type")
return