typecheck: diagnose CALL method before NEW

This commit is contained in:
Hermes Agent
2026-09-01 05:07:58 +00:00
parent a5c78cbfe1
commit 8153aed9cb
7 changed files with 20 additions and 5 deletions
+2 -1
View File
@@ -125,7 +125,7 @@ Type mismatch for method Player.add: parameter points needs NUMBER, but this arg
Both sides of this narrow method foundation are covered by validation: `tests/typecheck_method_good.claro` checks that `DO player.add 5` is accepted, and `tests/typecheck_method_bad.claro` checks the friendly wrong-type diagnostic.
If the method call comes before the object is created, the type checker now gives the learner the missing setup step:
If the method call comes before the object is created, the type checker now gives the learner the missing setup step. The modern `DO` form and the older compatibility `CALL ... WITH` form both get this guidance:
```claro
CLASS Player
@@ -138,6 +138,7 @@ CLASS Player
END
DO player.add 5
CALL player.add WITH 5
```
Output: