From 8698df86fbf255f905d81ef46bf212661091df97 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 4 May 2020 01:40:50 +0200 Subject: [PATCH] fixes #14207 --- compiler/dfa.nim | 4 ++-- tests/arc/tarcmisc.nim | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/compiler/dfa.nim b/compiler/dfa.nim index 0cefec2858d1d..7db5f5f65af50 100644 --- a/compiler/dfa.nim +++ b/compiler/dfa.nim @@ -541,8 +541,8 @@ template genNoReturn(c: var Con; n: PNode) = c.code.add Instr(n: n, kind: goto, dest: high(int) - c.code.len) proc genRaise(c: var Con; n: PNode) = - genJoins(c, n) gen(c, n[0]) + genJoins(c, n) if c.inTryStmt > 0: c.tryStmtFixups.add c.gotoI(n) else: @@ -553,11 +553,11 @@ proc genImplicitReturn(c: var Con) = gen(c, c.owner.ast[resultPos]) proc genReturn(c: var Con; n: PNode) = - genJoins(c, n) if n[0].kind != nkEmpty: gen(c, n[0]) else: genImplicitReturn(c) + genJoins(c, n) genNoReturn(c, n) const diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim index ce8e902c6b1ca..c0583a64045ac 100644 --- a/tests/arc/tarcmisc.nim +++ b/tests/arc/tarcmisc.nim @@ -1,5 +1,6 @@ discard """ output: ''' +123xyzabc destroyed: false destroyed: false closed @@ -8,6 +9,19 @@ destroying variable cmd: "nim c --gc:arc $file" """ +proc takeSink(x: sink string): bool = true + +proc b(x: sink string): string = + if takeSink(x): + return x & "abc" + +proc bbb(inp: string) = + let y = inp & "xyz" + echo b(y) + +bbb("123") + + # bug #13691 type Variable = ref object value: int