diff options
author | Araq <rumpf_a@web.de> | 2019-07-09 09:35:54 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2019-07-09 11:38:00 +0200 |
commit | f64179e7fe5703ec2045b869c9f381c01fb5dbd9 (patch) | |
tree | 9d77a2b96811b9bc5a056d52f99c0e13579b858c /compiler | |
parent | 7c62de0cb729185fb679bc53b52549cae7ab9fcc (diff) | |
download | Nim-f64179e7fe5703ec2045b869c9f381c01fb5dbd9.tar.gz |
bugfix: allow type conversions between 'owned ref' types
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semexprs.nim | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 6cf6f9acd..5c299b95b 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -220,6 +220,10 @@ proc maybeLiftType(t: var PType, c: PContext, info: TLineInfo) = closeScope(c) 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 = if sonsLen(n) != 2: 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) - 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 t = newTypeS(targetType.kind, c) if targetType.kind == tyOwned: |