diff options
-rw-r--r-- | compiler/isolation_check.nim | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/isolation_check.nim b/compiler/isolation_check.nim index 8c40dd4ad..01f0a002a 100644 --- a/compiler/isolation_check.nim +++ b/compiler/isolation_check.nim @@ -64,9 +64,18 @@ proc canAlias(arg, ret: PType; marker: var IntSet): bool = else: result = false +proc isValueOnlyType(t: PType): bool = + # t doesn't contain pointers and references + proc wrap(t: PType): bool {.nimcall.} = t.kind in {tyRef, tyPtr, tyVar, tyLent} + result = not types.searchTypeFor(t, wrap) + proc canAlias*(arg, ret: PType): bool = - var marker = initIntSet() - result = canAlias(arg, ret, marker) + if isValueOnlyType(arg): + # can alias only with unsafeAddr(arg.x) and we don't care if it is not safe + result = false + else: + var marker = initIntSet() + result = canAlias(arg, ret, marker) proc checkIsolate*(n: PNode): bool = if types.containsTyRef(n.typ): |