From b17f101cfc75565f9991c856ec62f1e17b0ab104 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sun, 18 Oct 2026 06:09:01 +0000 Subject: feat(operators): add member and unary overloads with explicit calls Select member and global candidates together, enforce private access, and reuse argument marshalling. Materialize temporary receivers for chaining and register them for the existing object cleanup mechanism. Co-Authored-By: Claude Opus 5.5 --- tests/iii/operator-member-errors/case.json | 20 ++++++++++++++++++++ tests/iii/operator-member-errors/notes.md | 3 +++ tests/iii/operator-member-errors/program.cps | 18 ++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 tests/iii/operator-member-errors/case.json create mode 100644 tests/iii/operator-member-errors/notes.md create mode 100644 tests/iii/operator-member-errors/program.cps (limited to 'tests/iii/operator-member-errors') diff --git a/tests/iii/operator-member-errors/case.json b/tests/iii/operator-member-errors/case.json new file mode 100644 index 0000000..1e8f8ae --- /dev/null +++ b/tests/iii/operator-member-errors/case.json @@ -0,0 +1,20 @@ +{ + "errors": [ + { + "reason": "Ambiguous overload", + "line": 14 + }, + { + "reason": "Cannot access private method", + "line": 15 + }, + { + "reason": "Cannot access private method", + "line": 16 + }, + { + "reason": "whole array cannot be used as an operand", + "line": 18 + } + ] +} diff --git a/tests/iii/operator-member-errors/notes.md b/tests/iii/operator-member-errors/notes.md new file mode 100644 index 0000000..204ab43 --- /dev/null +++ b/tests/iii/operator-member-errors/notes.md @@ -0,0 +1,3 @@ +# operator-member-errors + +Reject equally matching member/global candidates, implicit and explicit private access, and unary operations on whole arrays. diff --git a/tests/iii/operator-member-errors/program.cps b/tests/iii/operator-member-errors/program.cps new file mode 100644 index 0000000..9b48135 --- /dev/null +++ b/tests/iii/operator-member-errors/program.cps @@ -0,0 +1,18 @@ +CLASS Box +Value : INTEGER +OVERLOAD FUNCTION OPERATOR+(rhs : Box) RETURNS INTEGER +RETURN 1 +ENDFUNCTION +PRIVATE OVERLOAD FUNCTION OPERATOR&(rhs : STRING) RETURNS STRING +RETURN rhs +ENDFUNCTION +ENDCLASS +OVERLOAD FUNCTION OPERATOR+(lhs : Box, rhs : Box) RETURNS INTEGER +RETURN 2 +ENDFUNCTION +DECLARE a : Box +OUTPUT a + a +OUTPUT a & "x" +OUTPUT a.OPERATOR&("x") +DECLARE items : ARRAY[1:2] OF Box +OUTPUT NOT items -- cgit v1.3.1-4-g156e