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:
parent
3e060cfb0a
commit
b6fb609e0d
3 changed files with 22 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue