diff options
author | Araq <rumpf_a@web.de> | 2020-03-10 09:42:23 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2020-03-11 09:26:57 +0100 |
commit | b0684ec425dca5e76eb6b27eb09a84fb523af49c (patch) | |
tree | 96b3d6c9cbc4561407d86554a916fca3a6620b32 /compiler | |
parent | f95eef99a97dc813cf2f819a6bbaa3b3ead67267 (diff) | |
download | Nim-b0684ec425dca5e76eb6b27eb09a84fb523af49c.tar.gz |
fixes #12757
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semtypes.nim | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index abc5de7e8..f05affc6b 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -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 |