From e17ff862d7635d6413674f26e96edb7370f61f7e Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Tue, 8 Sep 2026 11:13:20 +0000 Subject: [PATCH] test: cover reverse text concatenation --- docs/ADVANCED_STATIC_TYPING.md | 8 ++++++++ docs/CURRENT_STATUS.md | 2 +- docs/ROADMAP.md | 2 +- tests/test_validate_typecheck_diagnostics.py | 6 ++++++ .../typecheck_object_field_text_concat_reverse_good.claro | 7 +++++++ tools/validate_typecheck_diagnostics.py | 1 + 6 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/typecheck_object_field_text_concat_reverse_good.claro diff --git a/docs/ADVANCED_STATIC_TYPING.md b/docs/ADVANCED_STATIC_TYPING.md index 998946b..f2d879a 100644 --- a/docs/ADVANCED_STATIC_TYPING.md +++ b/docs/ADVANCED_STATIC_TYPING.md @@ -156,6 +156,14 @@ SET player.name player.name + " Lovelace" The focused typecheck validation matrix covers this positive case beside the existing numeric-expression and text-operand checks. +The same rule works when the literal comes first: + +```claro +SET player.name "Ada " + player.name +``` + +This reverse-order concatenation is also covered by focused validation, so learners can build text from either side without losing the declared `TEXT` field type. + `CHECK TYPE` also preserves TEXT field metadata through the same chained aliases: ```claro diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md index b3562c1..54ab96e 100644 --- a/docs/CURRENT_STATUS.md +++ b/docs/CURRENT_STATUS.md @@ -57,7 +57,7 @@ Ready now: Still needed: - Keep the focused typecheck validator's fixture list complete as new positive and negative examples are added. -- The expression checker now carries a known TEXT operand through all arithmetic operators so object-field diagnostics do not hide addition, subtraction, multiplication, or division mistakes; focused numeric-subtraction, numeric-division, and numeric-multiplication positives plus text-operand addition, subtraction, multiplication, and division negatives protect this behavior. Text concatenation into a TEXT field also has a focused positive fixture. Each numeric operator names the text operand and explains that it needs NUMBER values. +- The expression checker now carries a known TEXT operand through all arithmetic operators so object-field diagnostics do not hide addition, subtraction, multiplication, or division mistakes; focused numeric-subtraction, numeric-division, and numeric-multiplication positives plus text-operand addition, subtraction, multiplication, and division negatives protect this behavior. Text concatenation into a TEXT field has focused positive fixtures for both operand orders. Each numeric operator names the text operand and explains that it needs NUMBER values. - richer typed function signatures and return values - type checking through branches and loops - richer object field type checking beyond simple direct assignments diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 6578da9..bf03fdc 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -36,7 +36,7 @@ See `CURRENT_STATUS.md` for the detailed feature matrix. 3b. Keep package security validation in Forgejo/Gitea CI so unsafe names, exact manifest-version/name/version/checksum mismatches, missing manifests, duplicate project manifest versions and packages, duplicate lock packages, duplicate package manifest names, versions, and checksums, and lockfile errors remain release blockers. 4. Add small examples for each foundation feature before adding bigger syntax. The object-field foundation now includes positive and negative validation for field expressions such as `SET player.score player.name`, `SET player.score player.score + 1`, `SET player.name player.score + 1`, explicitly typed field assignments, simple and chained aliases such as `SET alias player`, `SET backup alias`, followed by `SET backup.score ...` or `CHECK TYPE backup.score IS ...`, chained aliases in object-method calls through both modern `DO` and compatibility `CALL ... WITH` forms (including a dedicated positive modern `DO` fixture), and arithmetic/text expression mismatches; typed containers also accept a map with nested type metadata when it is added to a `LIST OF MAP`; broader alias/control-flow checking remains planned. 5. Keep the focused typecheck validator complete: every `typecheck_*.claro` fixture, including positive fixtures, must be exercised by release validation. -6. Continue narrowing expression diagnostics: known TEXT operands now remain visible through arithmetic, with focused numeric-subtraction, numeric-division, and numeric-multiplication positives plus text-operand addition, subtraction, multiplication, and division coverage. Text concatenation into TEXT fields is also covered as a positive case. Each numeric operator gives specific guidance naming the text operand. +6. Continue narrowing expression diagnostics: known TEXT operands now remain visible through arithmetic, with focused numeric-subtraction, numeric-division, and numeric-multiplication positives plus text-operand addition, subtraction, multiplication, and division coverage. Text concatenation into TEXT fields is covered in both operand orders. Each numeric operator gives specific guidance naming the text operand. ## Complete-platform milestones diff --git a/tests/test_validate_typecheck_diagnostics.py b/tests/test_validate_typecheck_diagnostics.py index b31b726..b90b793 100644 --- a/tests/test_validate_typecheck_diagnostics.py +++ b/tests/test_validate_typecheck_diagnostics.py @@ -34,6 +34,12 @@ class ValidateTypecheckDiagnosticsTests(unittest.TestCase): MODULE.EXPECTED_OK, ) + def test_includes_reverse_text_concatenation_success_fixture(self): + self.assertIn( + "tests/typecheck_object_field_text_concat_reverse_good.claro", + MODULE.EXPECTED_OK, + ) + if __name__ == "__main__": unittest.main() diff --git a/tests/typecheck_object_field_text_concat_reverse_good.claro b/tests/typecheck_object_field_text_concat_reverse_good.claro new file mode 100644 index 0000000..3be90a5 --- /dev/null +++ b/tests/typecheck_object_field_text_concat_reverse_good.claro @@ -0,0 +1,7 @@ +CLASS Player + HAS name TEXT +END + +NEW Player player +SET player.name "Lovelace" +SET player.name "Ada " + player.name diff --git a/tools/validate_typecheck_diagnostics.py b/tools/validate_typecheck_diagnostics.py index 59b8225..3f1bb70 100644 --- a/tools/validate_typecheck_diagnostics.py +++ b/tools/validate_typecheck_diagnostics.py @@ -182,6 +182,7 @@ EXPECTED_OK = [ "tests/typecheck_object_field_multiplication_good.claro", "tests/typecheck_object_field_text_good.claro", "tests/typecheck_object_field_text_concat_good.claro", + "tests/typecheck_object_field_text_concat_reverse_good.claro", "tests/typecheck_object_field_yesno_good.claro", "tests/typecheck_object_field_check_type_number_good.claro", "tests/typecheck_object_field_check_type_text_good.claro",