mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 14:25:23 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user