test: cover text operands in multiplication diagnostics

This commit is contained in:
Hermes Agent
2026-09-07 06:30:38 +00:00
parent 2cf5aaf3a9
commit 562e53b3b4
5 changed files with 23 additions and 2 deletions
+10
View File
@@ -99,6 +99,16 @@ SET player.score player.score - player.name
Type mismatch for field player.score: expected NUMBER, but this value looks like TEXT.
```
The same learner-facing result is preserved for multiplication, so the checker does not lose the useful `TEXT` type when the invalid expression uses `*`:
```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:
+1 -1
View File
@@ -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 subtraction, multiplication, or division mistakes; operator-specific diagnostics remain planned.
- The expression checker now carries a known TEXT operand through all arithmetic operators so object-field diagnostics do not hide subtraction, multiplication, or division mistakes; focused subtraction and multiplication fixtures protect this behavior, while operator-specific diagnostics remain planned.
- richer typed function signatures and return values
- type checking through branches and loops
- richer object field type checking beyond simple direct assignments
+1 -1
View File
@@ -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, while 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 and multiplication coverage; operator-specific guidance is still future work.
## Complete-platform milestones
@@ -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
+3
View File
@@ -113,6 +113,9 @@ EXPECTED = {
"tests/typecheck_object_field_subtraction_bad.claro": [
"tests/typecheck_object_field_subtraction_bad.claro:8: Type mismatch for field player.score: expected NUMBER, but this value looks like TEXT.",
],
"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_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.",
],