typecheck: diagnose CALL method before NEW typos

This commit is contained in:
Hermes Agent
2026-09-01 11:18:58 +00:00
parent 73f5395b28
commit a9612c5074
7 changed files with 22 additions and 5 deletions
+2 -1
View File
@@ -178,10 +178,11 @@ DO player.add "five"
Type mismatch for method Player.add: parameter points needs NUMBER, but this argument looks like TEXT.
```
If a learner calls a simple object method before creating the object with `NEW`, `claro typecheck` now points to the missing setup instead of letting the dotted call look like an ordinary unknown function. This covers both the modern `DO player.add 5` form and the older compatibility `CALL player.add WITH 5` form:
If a learner calls a simple object method before creating the object with `NEW`, `claro typecheck` now points to the missing setup instead of letting the dotted call look like an ordinary unknown function. This covers both the modern `DO player.add 5` form and the older compatibility `CALL player.add WITH 5` form, including `CALL` mistakes where the method name itself is wrong:
```text
Object player is not known yet. Create it with NEW ClassName player before calling player.add.
Object player is not known yet. Create it with NEW ClassName player before calling player.fly.
```
If the object exists but the class does not declare that method, Claro now names the class and suggests where to add the missing `TEACH` block: