typecheck: name methods in field diagnostics

This commit is contained in:
Hermes Agent
2026-09-13 10:58:08 +00:00
parent 8e9ab3c711
commit 915bc7f1bc
9 changed files with 42 additions and 8 deletions
+1 -1
View File
@@ -825,7 +825,7 @@ Output:
Function greet needs 1 argument, but this call gives 0. Add the missing argument.
```
The same operator-specific diagnostic is used inside a typed method when it updates a class field by its simple name. For example, `SET score score + name` inside `Player.add RETURNS NUMBER` reports `Type mismatch for field score in Player.add: addition needs NUMBER values, but name looks like TEXT.` instead of describing the field as an ordinary variable. This focused check covers typed method bodies; broader control-flow and object-flow analysis remains planned.
The same method-aware diagnostic is used when a method directly assigns the wrong value to a class field. For example, `SET name 123` inside `Player.rename` reports `Type mismatch for field name in Player.rename: expected TEXT, but this value looks like NUMBER.` The operator-specific form also remains available: `SET score score + name` inside `Player.add RETURNS NUMBER` reports `Type mismatch for field score in Player.add: addition needs NUMBER values, but name looks like TEXT.` These focused checks cover typed method bodies; broader control-flow and object-flow analysis remains planned.
## Status