fixes #12757
This commit is contained in:
parent
f95eef99a9
commit
b0684ec425
1 changed files with 13 additions and 6 deletions
|
|
@ -893,7 +893,7 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
|||
localError(c.config, n.info, "type '$1 void' is not allowed" % kindToStr[kind])
|
||||
result = newOrPrevType(kind, prev, c)
|
||||
var isNilable = false
|
||||
var isOwned = false
|
||||
var wrapperKind = tyNone
|
||||
# check every except the last is an object:
|
||||
for i in isCall..<n.len-1:
|
||||
let ni = n[i]
|
||||
|
|
@ -901,8 +901,8 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
|||
isNilable = true
|
||||
else:
|
||||
let region = semTypeNode(c, ni, nil)
|
||||
if region.kind == tyOwned:
|
||||
isOwned = true
|
||||
if region.kind in {tyOwned, tySink}:
|
||||
wrapperKind = region.kind
|
||||
elif region.skipTypes({tyGenericInst, tyAlias, tySink}).kind notin {
|
||||
tyError, tyObject}:
|
||||
message c.config, n[i].info, errGenerated, "region needs to be an object type"
|
||||
|
|
@ -914,11 +914,18 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
|||
if tfPartial in result.flags:
|
||||
if result.lastSon.kind == tyObject: incl(result.lastSon.flags, tfPartial)
|
||||
#if not isNilable: result.flags.incl tfNotNil
|
||||
if isOwned and optOwnedRefs in c.config.globalOptions:
|
||||
let t = newTypeS(tyOwned, c)
|
||||
t.flags.incl tfHasOwned
|
||||
case wrapperKind
|
||||
of tyOwned:
|
||||
if optOwnedRefs in c.config.globalOptions:
|
||||
let t = newTypeS(tyOwned, c)
|
||||
t.flags.incl tfHasOwned
|
||||
t.rawAddSonNoPropagationOfTypeFlags result
|
||||
result = t
|
||||
of tySink:
|
||||
let t = newTypeS(tySink, c)
|
||||
t.rawAddSonNoPropagationOfTypeFlags result
|
||||
result = t
|
||||
else: discard
|
||||
#if result.kind == tyRef and c.config.selectedGC == gcDestructors:
|
||||
# result.flags.incl tfHasAsgn
|
||||
# XXX Something like this is a good idea but it should be done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue