diff options
| author | 2026-10-15 02:35:44 +0330 | |
|---|---|---|
| committer | 2026-10-15 02:40:51 +0330 | |
| commit | 3de6ae4a6a74b2c4fa14c3f2d6fbfff3bb83c5f5 (patch) | |
| tree | 577ac1025bb02a11069cf288a38bfc5120e8402d /tests/conformance/6-ownership/drop_no_move_out_field.zc | |
| parent | destructors: reassigning an m owner that still holds a value frees the old va... (diff) | |
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
Diffstat (limited to 'tests/conformance/6-ownership/drop_no_move_out_field.zc')
| -rw-r--r-- | tests/conformance/6-ownership/drop_no_move_out_field.zc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/conformance/6-ownership/drop_no_move_out_field.zc b/tests/conformance/6-ownership/drop_no_move_out_field.zc new file mode 100644 index 0000000..e4d863c --- /dev/null +++ b/tests/conformance/6-ownership/drop_no_move_out_field.zc @@ -0,0 +1,13 @@ +// expect error: b: can't move out of a value with drop +// destructors 6.15.5: an array that is a field of a value with a drop is part of it, so pop on it is refused too +include rt; +struct bag { int*[?] items; void drop() { rt.put_s("bag drop\n"); } } +fn main() { + bag* b = rt.new(bag); + b.items = rt.new(int*[?]); + int* x = rt.new(int); *x = 5; b.items.push(x); + int* y = b.items.pop(); + rt.put_n(*y); + return 0; +} +// zc0: skip |
