mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
fixes #12757
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user