Files
carbon-lang/explorer/testdata/destructor/destroy_array.carbon
T
cef93fba5e Feature call destructor for tuples and bug fixes for the destructor process (#2255)
This PR includes the following changes:
*  Added destruction process for tuples
*  Fix: In the current version only the last member of a object can be destroyed
*  Fix: In the current version, the destructor of the object is called after each method call 

I hope it is useful

Co-authored-by: m new <michael.burzan@outlook.de>
Co-authored-by: Geoff Romer <gromer@google.com>
2022-11-04 12:13:24 -07:00

31 lines
750 B
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{explorer-run}
// RUN: %{explorer-run-trace}
// CHECK:STDOUT: DESTRUCTOR A 1
// CHECK:STDOUT: DESTRUCTOR A 2
// CHECK:STDOUT: DESTRUCTOR A 3
// CHECK:STDOUT: DESTRUCTOR A 4
// CHECK:STDOUT: DESTRUCTOR A 5
// CHECK:STDOUT: DESTRUCTOR A 6
// CHECK:STDOUT: result: 1
package ExplorerTest api;
class A{
destructor[me: Self]{
Print("DESTRUCTOR A {0}",me.n);
}
var n: i32;
}
fn Main() -> i32 {
var a: [A; 2] = ({.n = 6},{.n = 5});
var b: [[A; 2]; 2] = (({.n = 4},{.n = 3}), ({.n = 2},{.n = 1}));
return 1;
}