From 5a67f4e3833c2acca4a351f5dd613bc08f04bfc0 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sun, 18 Oct 2026 06:11:42 +0000 Subject: feat(operators): document overloads and cover remaining operator forms Add fixed cases for every supported operator, imported global and member operators, CASE comparisons, and declared result type errors. Document syntax, exact matching, access rules and temporary receiver lifetimes. Co-Authored-By: Claude Opus 5.5 --- tests/iii/operator-result-errors/case.json | 20 ++++++++++++++++++++ tests/iii/operator-result-errors/notes.md | 3 +++ tests/iii/operator-result-errors/program.cps | 20 ++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/iii/operator-result-errors/case.json create mode 100644 tests/iii/operator-result-errors/notes.md create mode 100644 tests/iii/operator-result-errors/program.cps (limited to 'tests/iii/operator-result-errors') diff --git a/tests/iii/operator-result-errors/case.json b/tests/iii/operator-result-errors/case.json new file mode 100644 index 0000000..67abec2 --- /dev/null +++ b/tests/iii/operator-result-errors/case.json @@ -0,0 +1,20 @@ +{ + "errors": [ + { + "reason": "Cannot implicitly convert STRING to BOOLEAN", + "line": 8 + }, + { + "reason": "Cannot implicitly convert STRING to BOOLEAN", + "line": 12 + }, + { + "reason": "Cannot implicitly convert STRING to BOOLEAN", + "line": 17 + }, + { + "reason": "CASE comparison must return BOOLEAN", + "line": 19 + } + ] +} diff --git a/tests/iii/operator-result-errors/notes.md b/tests/iii/operator-result-errors/notes.md new file mode 100644 index 0000000..bb407a2 --- /dev/null +++ b/tests/iii/operator-result-errors/notes.md @@ -0,0 +1,3 @@ +# operator-result-errors + +The equality operator returns STRING. Reject that result as an IF condition, BOOLEAN return value, BOOLEAN argument and CASE comparison. diff --git a/tests/iii/operator-result-errors/program.cps b/tests/iii/operator-result-errors/program.cps new file mode 100644 index 0000000..8cf9ede --- /dev/null +++ b/tests/iii/operator-result-errors/program.cps @@ -0,0 +1,20 @@ +CLASS Box +Value : INTEGER +OVERLOAD FUNCTION OPERATOR=(rhs : Box) RETURNS STRING +RETURN "text" +ENDFUNCTION +ENDCLASS +DECLARE item : Box +IF item = item THEN +OUTPUT "wrong" +ENDIF +FUNCTION Bad(value : Box) RETURNS BOOLEAN +RETURN value = value +ENDFUNCTION +FUNCTION NeedBool(flag : BOOLEAN) RETURNS INTEGER +RETURN 0 +ENDFUNCTION +OUTPUT NeedBool(item = item) +CASE OF item +item : OUTPUT "wrong" +ENDCASE -- cgit v1.3.1-4-g156e