You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pair with the tree-sitter-rad grammar change introducing the
typed_assign rule and the BLOCK_COLON external token. This commit
handles the rad-side wiring: converter -> AST -> binder -> type
checker -> tests, plus snapshot updates from the CST shape change.
The converter desugars typed_assign into the existing Assign AST
node with a new optional DeclaredType field. Keeping a single
Assign kind downstream means every existing pass (walkAST, binder
visit dispatch, interpreter exec) stays unchanged; the only new
concept is 'this Assign carries an annotation.' One AST shape,
two source forms.
Symbol gains a Declared slot. The binder reads it from
Assign.DeclaredType the moment a typed local is declared, and the
type checker enforces the annotation on both the initial RHS AND
every subsequent reassignment - the annotation is sticky for the
binding's lifetime. Untyped locals stay completely unchanged: no
Declared, no reassignment constraint, no diagnostic.
The grammar's external-scanner trick (BLOCK_COLON only emitted
when ':' is followed by a newline) means variables named exactly
`rad` / `request` / `display` ALSO carry annotations
unambiguously - `rad: int = 5` parses as a typed_assign, not a
rad_block. A dedicated test pins that down so any future grammar
regression on the scanner peek surfaces immediately.
Severity stays at Hint, consistent with the rest of Phase 2's
assignability checks (per-arg type-check, op overload). The
runtime still produces its richer value-aware message when it
runs; the static check just surfaces the issue earlier in LSP and
rad check. One severity-migration pass will flip every
assignability check together once literal-type fidelity exists.
The ST snapshot updates are mechanical: rad_block's CST no longer
contains a visible `:` literal child (BLOCK_COLON is a hidden
external token) so the dump lines for that node disappear.
AST shapes are unchanged.
0 commit comments