From be964b4df4db9f42e0b7d615c1cbfa6cf268e646 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 20 Oct 2026 12:01:45 +0000 Subject: fix(strings): preserve enclosing class lifetimes during assignment Copy owned string fields without reconstructing or destroying their containing class, and retain rvalue ownership transfers. Co-Authored-By: Claude Opus 5.5 --- tests/i/string-aggregate-assignment/program.cps | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/i/string-aggregate-assignment/program.cps (limited to 'tests/i/string-aggregate-assignment/program.cps') diff --git a/tests/i/string-aggregate-assignment/program.cps b/tests/i/string-aggregate-assignment/program.cps new file mode 100644 index 0000000..9659437 --- /dev/null +++ b/tests/i/string-aggregate-assignment/program.cps @@ -0,0 +1,28 @@ +GLOBAL + DECLARE Destroyed : INTEGER + DECLARE Copies : INTEGER +ENDGLOBAL +CLASS Box + Text : STRING + OVERLOAD PROCEDURE NEW() + ENDPROCEDURE + OVERLOAD PROCEDURE NEW(BYREF Other : Box) + Text <- Other.Text + Copies <- Copies + 1 + ENDPROCEDURE + PROCEDURE DELETE() + Destroyed <- Destroyed + 1 + ENDPROCEDURE +ENDCLASS +PROCEDURE Check() + DECLARE A : Box + DECLARE B : Box + A.Text <- "left" + B.Text <- "right" + B <- A + B <- B + B.Text <- "changed" + OUTPUT A.Text, ":", B.Text, ":", Destroyed, ":", Copies +ENDPROCEDURE +CALL Check() +OUTPUT Destroyed, ":", Copies -- cgit v1.3.1-4-g156e