typecheck: diagnose missing object names

This commit is contained in:
Hermes Agent
2026-09-17 08:28:23 +00:00
parent b0dbe976de
commit 6dcb86b920
7 changed files with 19 additions and 3 deletions
+1 -1
View File
@@ -191,7 +191,7 @@ Object methods must also have unique names within their class. If `CLASS Player`
Class fields must also have unique names and known types. If `CLASS Player` declares `HAS score NUMBER` twice, or declares the same field with another type, `claro typecheck` reports `Class Player declares field score more than once. Give each field a different name.` If a field omits its type, it reports `Class Player field score is missing a type. Add a type such as NUMBER, TEXT, YESNO, LIST, or MAP after the field name.` If a field uses an unknown type such as `BANANA`, it reports `Class Player field score uses an unknown type BANANA. Use a Claro type such as NUMBER, TEXT, YESNO, LIST, or MAP.` If extra text follows a valid type, it reports `Class Player field score has extra text after type NUMBER. Keep only the field name and one type.` Keep one `HAS` line for each field and use one supported type.
Class declarations must include a name. A bare `CLASS` reports `CLASS needs a class name. Add a name after CLASS, such as CLASS Player.` Class names must also be unique and use one name only. If a file declares `CLASS Player` twice, `claro typecheck` reports `Class Player is declared more than once. Give each class a different name.` If extra words follow the name, it reports `Class Player has extra text after its name. Keep only the class name after CLASS.` Rename or simplify the declaration before creating its objects. Object names must also be unique within a script: creating `NEW Player player` twice reports `Object player is created more than once. Give each object a different name.` Use a different object name for the second instance.
Class declarations must include a name. A bare `CLASS` reports `CLASS needs a class name. Add a name after CLASS, such as CLASS Player.` Class names must also be unique and use one name only. If a file declares `CLASS Player` twice, `claro typecheck` reports `Class Player is declared more than once. Give each class a different name.` If extra words follow the name, it reports `Class Player has extra text after its name. Keep only the class name after CLASS.` Rename or simplify the declaration before creating its objects. Object names must also be unique within a script: creating `NEW Player player` twice reports `Object player is created more than once. Give each object a different name.` Use a different object name for the second instance. A `NEW` declaration must include an object name; `NEW Player` reports `NEW Player needs an object name. Add a name after the class, such as NEW Player player.`
Extra words after an object name are also rejected, for example `NEW Player player extra` reports `NEW Player has extra text after object name player. Keep only the class and object names.` Keep each `NEW` declaration to one class name and one object name.
Simple functions and object methods can also declare a return type. `claro typecheck` checks each `RETURN` expression against it and reports a missing return when a declaration never returns a value: