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