bugfix: allow type conversions between 'owned ref' types
This commit is contained in:
parent
7c62de0cb7
commit
f64179e7fe
1 changed files with 5 additions and 1 deletions
|
|
@ -220,6 +220,10 @@ proc maybeLiftType(t: var PType, c: PContext, info: TLineInfo) =
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
if lifted != nil: t = lifted
|
if lifted != nil: t = lifted
|
||||||
|
|
||||||
|
proc isOwnedSym(c: PContext; n: PNode): bool =
|
||||||
|
let s = qualifiedLookUp(c, n, {})
|
||||||
|
result = s != nil and sfSystemModule in s.owner.flags and s.name.s == "owned"
|
||||||
|
|
||||||
proc semConv(c: PContext, n: PNode): PNode =
|
proc semConv(c: PContext, n: PNode): PNode =
|
||||||
if sonsLen(n) != 2:
|
if sonsLen(n) != 2:
|
||||||
localError(c.config, n.info, "a type conversion takes exactly one argument")
|
localError(c.config, n.info, "a type conversion takes exactly one argument")
|
||||||
|
|
@ -247,7 +251,7 @@ proc semConv(c: PContext, n: PNode): PNode =
|
||||||
|
|
||||||
maybeLiftType(targetType, c, n[0].info)
|
maybeLiftType(targetType, c, n[0].info)
|
||||||
|
|
||||||
if targetType.kind in {tySink, tyLent, tyOwned}:
|
if targetType.kind in {tySink, tyLent} or isOwnedSym(c, n[0]):
|
||||||
let baseType = semTypeNode(c, n.sons[1], nil).skipTypes({tyTypeDesc})
|
let baseType = semTypeNode(c, n.sons[1], nil).skipTypes({tyTypeDesc})
|
||||||
let t = newTypeS(targetType.kind, c)
|
let t = newTypeS(targetType.kind, c)
|
||||||
if targetType.kind == tyOwned:
|
if targetType.kind == tyOwned:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue