Skip to content

Commit

Permalink
fixes #14207
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed May 3, 2020
1 parent dfa7e23 commit 8698df8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/dfa.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests/arc/tarcmisc.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
discard """
output: '''
123xyzabc
destroyed: false
destroyed: false
closed
Expand All @@ -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
Expand Down

0 comments on commit 8698df8

Please sign in to comment.