From 74b6d06711afd3efbbc47436f1491900994313f3 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 06:54:32 +0000 Subject: feat(classes): allocate objects with NEW and rebind named class variables Co-Authored-By: Claude Opus 5.5 --- tests/iii/class-new-errors/case.json | 32 ++++++++++++++++++++++++++++++++ tests/iii/class-new-errors/program.cps | 26 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tests/iii/class-new-errors/case.json create mode 100644 tests/iii/class-new-errors/program.cps (limited to 'tests/iii/class-new-errors') diff --git a/tests/iii/class-new-errors/case.json b/tests/iii/class-new-errors/case.json new file mode 100644 index 0000000..8ce52ed --- /dev/null +++ b/tests/iii/class-new-errors/case.json @@ -0,0 +1,32 @@ +{ + "errors": [ + { + "reason": "NEW target must have type Other", + "line": 20 + }, + { + "reason": "NEW requires a class type", + "line": 21 + }, + { + "reason": "NEW requires a class type", + "line": 22 + }, + { + "reason": "has no constructor NEW", + "line": 23 + }, + { + "reason": "Incorrect # arguments passed to Required.NEW", + "line": 24 + }, + { + "reason": "Incorrect # arguments passed to Required.NEW", + "line": 25 + }, + { + "reason": "NEW target must have type Hidden", + "line": 26 + } + ] +} diff --git a/tests/iii/class-new-errors/program.cps b/tests/iii/class-new-errors/program.cps new file mode 100644 index 0000000..3a9e9c2 --- /dev/null +++ b/tests/iii/class-new-errors/program.cps @@ -0,0 +1,26 @@ +CLASS Box + Value : INTEGER +ENDCLASS +CLASS Other + Value : INTEGER +ENDCLASS +CLASS Required + PROCEDURE NEW(Number : INTEGER) + ENDPROCEDURE +ENDCLASS +CLASS Hidden + PRIVATE PROCEDURE NEW() + ENDPROCEDURE +ENDCLASS +TYPE RecordValue + DECLARE Value : INTEGER +ENDTYPE +DECLARE B : Box +DECLARE R : Required(1) +B <- NEW Other +B <- NEW INTEGER +B <- NEW RecordValue +B <- NEW Box(1) +R <- NEW Required +R <- NEW Required() +B <- NEW Hidden -- cgit v1.3.1-4-g156e