destructors: don't produce stupid code for 'cast' (#14208) [backport:1.2]

* destructors: don't produce stupid code for 'cast'

* fixes #14207
This commit is contained in:
Andreas Rumpf
2020-05-04 07:43:22 +02:00
committed by GitHub
parent 3e060cfb0a
commit b6fb609e0d
3 changed files with 22 additions and 4 deletions

View File

@@ -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