From b6fb609e0d263a209c6db48dd367f13eb7f4ff87 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 4 May 2020 07:43:22 +0200 Subject: destructors: don't produce stupid code for 'cast' (#14208) [backport:1.2] * destructors: don't produce stupid code for 'cast' * fixes #14207 --- tests/arc/tarcmisc.nim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/arc') diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim index ce8e902c6..c0583a640 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 -- cgit 1.4.1-2-gfad0