From 7d4f70280ef33192dc5862f8b4c4d23e9d956b40 Mon Sep 17 00:00:00 2001 From: Fanael Linithien Date: Thu, 12 Nov 2020 09:28:32 +0100 Subject: [PATCH] Fix #15909 (#15914) --- compiler/varpartitions.nim | 1 + tests/arc/t15909.nim | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/arc/t15909.nim diff --git a/compiler/varpartitions.nim b/compiler/varpartitions.nim index 2e781c0419..63c18d94af 100644 --- a/compiler/varpartitions.nim +++ b/compiler/varpartitions.nim @@ -399,6 +399,7 @@ proc allRoots(n: PNode; result: var seq[PSym]; followDotExpr = true) = proc destMightOwn(c: var Partitions; dest: var VarIndex; n: PNode) = ## Analyse if 'n' is an expression that owns the data, if so mark 'dest' ## with 'ownsData'. + if n.typ == nil: return case n.kind of nkEmpty, nkCharLit..nkNilLit: # primitive literals including the empty are harmless: diff --git a/tests/arc/t15909.nim b/tests/arc/t15909.nim new file mode 100644 index 0000000000..f25c89daf3 --- /dev/null +++ b/tests/arc/t15909.nim @@ -0,0 +1,16 @@ +discard """ + action: run + cmd: "nim c --gc:arc $file" +""" + +proc f1() {.noreturn.} = raise newException(CatchableError, "") + +proc f2(y: int): int = + if y != 0: + y + else: + f1() + +doAssert f2(5) == 5 +doAssertRaises(CatchableError): + discard f2(0)