feat: add typed function argument diagnostics

This commit is contained in:
Hermes Agent
2026-06-08 10:20:30 -06:00
parent 078b7874d3
commit 9c5202cd2c
9 changed files with 99 additions and 4 deletions
+31 -1
View File
@@ -43,6 +43,36 @@ Output:
Type mismatch for map scores: expected NUMBER value, but this value looks like TEXT.
```
## Function parameter checks
Claro now has a small static-checking foundation for function arguments. Keep the beginner-friendly function syntax, then put the expected type inside the function with `CHECK TYPE`:
```claro
TEACH square amount
CHECK TYPE amount IS NUMBER
SAY amount
END
DO square 4
```
If a learner calls the function with the wrong kind of value, `claro typecheck` explains which parameter needs which type:
```claro
TEACH square amount
CHECK TYPE amount IS NUMBER
SAY amount
END
DO square "oops"
```
Output:
```text
Type mismatch for function square: parameter amount needs NUMBER, but this argument looks like TEXT.
```
## Status
This is currently a static checker feature. It improves `claro typecheck` and validation confidence. Runtime enforcement for every container mutation can be added later after the syntax is classroom-tested.
This is currently a static checker feature. It improves `claro typecheck` and validation confidence. Runtime enforcement for every container mutation and richer function signatures can be added later after the syntax is classroom-tested.