From 3de6ae4a6a74b2c4fa14c3f2d6fbfff3bb83c5f5 Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 02:35:44 +0330 Subject: destructors: nothing moves out of a value with a drop: pop on an array with a drop, or on an array field of a value with a drop, is error: a: can't move out of a value with drop (fields were already borrowed projections); spec 6.15.5, four conformance programs --- tests/conformance/6-ownership/drop_no_move_out_pop.zc | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/conformance/6-ownership/drop_no_move_out_pop.zc (limited to 'tests/conformance/6-ownership/drop_no_move_out_pop.zc') diff --git a/tests/conformance/6-ownership/drop_no_move_out_pop.zc b/tests/conformance/6-ownership/drop_no_move_out_pop.zc new file mode 100644 index 0000000..3ee248f --- /dev/null +++ b/tests/conformance/6-ownership/drop_no_move_out_pop.zc @@ -0,0 +1,11 @@ +// expect error: a: can't move out of a value with drop +// destructors 6.15.5: pop moves an element out, so it is refused on an array with a drop, whose drop may need the element +include rt; +fn main() { + int*[?] a = drop(rt.new(int*[?]), fn() { rt.put_s("arr drop\n"); }); + int* x = rt.new(int); *x = 5; a.push(x); + int* y = a.pop(); + rt.put_n(*y); + return 0; +} +// zc0: skip -- cgit v1.2.3