feat(lang): L4 type checker between parse and emit

selfhost/check/ walks every function, the entry, tests, globals' initializers and
@On listeners with real scopes, and refuses mixed number kinds, text and numbers,
two record types, mismatched slices and fn types, wrong argument counts, wrong
returns and wrong push elements - every mix-up at once, each at its line.
LUDIC_CHECK_REPORT=1 lists them by category. pointer stays untyped (L7's).

What it found is fixed: render3d's HDR scan calling the float-bits extern f_lt
with floats; ludic.shooter's right-stick aim overflowing past half a push;
prof.ludic storing longs in []int; extern arguments now coerced to their
parameters. Text-returning runtime functions say string; Assets.ready says bool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-24 01:34:49 +03:00
parent 0677aee93f
commit 57b66bdf47
52 changed files with 27005 additions and 11844 deletions

16
changes/type-checker.md Normal file
View file

@ -0,0 +1,16 @@
bump: minor
type: feature
**A type checker runs before the emitter.** Numbers of different kinds, text and numbers, two
record types, slices of different elements and functions of different types no longer mix; a call
with the wrong number of arguments, a `return` of the wrong type and a `push` of the wrong element
are errors with a line - several of these reached clang as an IR error, or compiled and ran wrong.
Every mix-up is reported in one run. `pointer` stays untyped. `LUDIC_CHECK_REPORT=1` lists them by
category without failing.
It found, and this release fixes: render3d's HDR sky scan calling the float-bits extern `f_lt` with
floats (it passed them in float registers the callee never read); `ludic.shooter`'s right-stick aim
scaling a fixed deflection by 65536 again, which overflowed past half a push and turned the aim
round; `prof.ludic` storing longs in an `[]int`; and extern calls, whose arguments are now coerced
to their parameters like a function's. Runtime functions that return text (`Json.encode`, the
value, XML, Tiled, HTTP and regex readers, `gl_get_string`) say `string`, and `Assets.ready()`
says `bool`.