typecheck: reject duplicate class fields

This commit is contained in:
Hermes Agent
2026-09-16 03:30:52 +00:00
parent edcfd697f6
commit eddb3ba067
7 changed files with 18 additions and 2 deletions
+2
View File
@@ -181,6 +181,8 @@ The same declaration check applies to object methods in both syntax styles. For
Object methods must also have unique names within their class. If `CLASS Player` declares `TEACH show` twice, `claro typecheck` reports `Method Player.show is declared more than once. Give each method a different name.` Rename one method before calling it.
Class fields must also have unique names. 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.` Keep one `HAS` line for each field.
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:
```claro