From e4d4db3541bb4f2dc0b61ca2f0ab0d3bd0b30036 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Mon, 7 Sep 2026 08:32:41 +0000 Subject: [PATCH] test: cover division text operand diagnostics --- docs/ADVANCED_STATIC_TYPING.md | 10 ++++++++++ docs/ROADMAP.md | 2 +- tests/typecheck_object_field_division_bad.claro | 8 ++++++++ tools/validate_typecheck_diagnostics.py | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/typecheck_object_field_division_bad.claro diff --git a/docs/ADVANCED_STATIC_TYPING.md b/docs/ADVANCED_STATIC_TYPING.md index ca68be4..de7a172 100644 --- a/docs/ADVANCED_STATIC_TYPING.md +++ b/docs/ADVANCED_STATIC_TYPING.md @@ -109,6 +109,16 @@ SET player.score player.score * player.name Type mismatch for field player.score: expected NUMBER, but this value looks like TEXT. ``` +Division is covered in the same way: + +```claro +SET player.score player.score / player.name +``` + +```text +Type mismatch for field player.score: expected NUMBER, but this value looks like TEXT. +``` + The expression checker still deliberately reports only the type it can infer; full operator-specific rules remain future work. `CHECK TYPE` also preserves TEXT field metadata through the same chained aliases: diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 9375f94..173e09b 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 non-concatenation arithmetic, with focused subtraction and multiplication coverage; operator-specific guidance is still future work. +6. Continue narrowing expression diagnostics: known TEXT operands now remain visible through non-concatenation arithmetic, with focused subtraction, multiplication, and division coverage; operator-specific guidance is still future work. ## Complete-platform milestones diff --git a/tests/typecheck_object_field_division_bad.claro b/tests/typecheck_object_field_division_bad.claro new file mode 100644 index 0000000..166dfb5 --- /dev/null +++ b/tests/typecheck_object_field_division_bad.claro @@ -0,0 +1,8 @@ +CLASS Player + HAS name TEXT + HAS score NUMBER +END + +NEW Player player +SET player.name "Ada" +SET player.score player.score / player.name diff --git a/tools/validate_typecheck_diagnostics.py b/tools/validate_typecheck_diagnostics.py index f7b9987..62ff1a4 100644 --- a/tools/validate_typecheck_diagnostics.py +++ b/tools/validate_typecheck_diagnostics.py @@ -116,6 +116,9 @@ EXPECTED = { "tests/typecheck_object_field_multiplication_bad.claro": [ "tests/typecheck_object_field_multiplication_bad.claro:8: Type mismatch for field player.score: expected NUMBER, but this value looks like TEXT.", ], + "tests/typecheck_object_field_division_bad.claro": [ + "tests/typecheck_object_field_division_bad.claro:8: Type mismatch for field player.score: expected NUMBER, but this value looks like TEXT.", + ], "tests/typecheck_object_field_text_expression_bad.claro": [ "tests/typecheck_object_field_text_expression_bad.claro:8: Type mismatch for field player.name: expected TEXT, but this value looks like NUMBER.", ],