Files
carbon-lang/explorer/testdata/destructor/self_addr.carbon
T
Lucile Rose Nihlen af0710ea16 Add addr self binding support in destructors (#3117)
Refactors `CallDestructor` and `CallFunction` to both call a new method
`BindSelfIfPresent`, which includes support for binding `addr self` if
specified. Fixes the associated unit test.

Closes #2802.
2023-08-29 20:46:39 +00:00

25 lines
477 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
package ExplorerTest impl;
class A {
destructor[addr self: Self*] {
self->n += 1;
Print("DESTRUCTOR A {0}", self->n);
}
var n: i32;
}
fn Main() -> i32 {
var a: A = {.n = 2};
return 0;
}
// CHECK:STDOUT: DESTRUCTOR A 3
// CHECK:STDOUT: result: 0