typecheck: diagnose unknown NEW classes

This commit is contained in:
Hermes Agent
2026-09-16 13:50:00 +00:00
parent 7eff213a78
commit 139838d56e
7 changed files with 25 additions and 2 deletions
+6
View File
@@ -109,6 +109,12 @@ OBJECT CLASS player AS kind
OBJECT FIELDS player AS fields
```
When a script already declares classes, `claro typecheck` also catches a typo in a `NEW` class name and explains how to repair it:
```text
Class Plaeyr is not known yet. Check the class name or declare CLASS Plaeyr before creating player.
```
Inside a method, an inline field type must agree with the class declaration. For example, `HAS score NUMBER` must not be assigned with `SET score TEXT 10`; `claro typecheck` explains the conflict and suggests `NUMBER`. The same check applies to older `TEACH ... TAKES ...` / `LEARNED` methods, so compatibility lessons get the same feedback.
If an inline method-field annotation is not a Claro type, `claro typecheck` names the field and method and suggests the class declaration. For example, `SET score AS BANANA TO 10` reports that `BANANA` is unknown and recommends `NUMBER`.