Repository navigation
v2.21.0 - Document the null-safety surface; fix Kotlin `?[` and Lua `null`
The README's feature tables covered control flow, operators and OOP — but nothing of the null-safety work from 2.16.0 through 2.20.0. Five releases of behaviour were documented only in the changelog.
New: a Null safety section
A per-language table for nullable types (T?), ?? / ??=, ?. / ?[, !, cascades, == null, and the static analyzer.
Every cell was verified by generating the construct into each target and reading the output, not written from memory. That mattered — it caught two targets emitting source that is not valid in their language.
The table introduces a
- ✅ native — the target has the operator (Kotlin
?:, TS?., C#??). - 🧩 idiom — a faithful desugaring (Java's ternary for
??, Lua's IIFE with an explicitniltest, Go's(*a)for!). ⚠️ lossy — compiles, but the null check is dropped (a?.x→a.x,a!→a). Correct-looking output with different runtime behaviour, which the single🧩marker used to hide.
?? / ??= are never lossy: every target either has the operator or gets a faithful desugaring.
Two bugs found while doing it
- Kotlin's null-aware index was
xs?[0]. Kotlin has no?[operator — it is the callxs?.get(0). The sharednullAwareIndexOpenhook gained a matchingnullAwareIndexClose, so a target can close with)instead of]. - Lua's null literal was
null. Lua's isnil, so the generated source referenced an undefined global anda == nullwas always false rather than a nil test.
Also
- A Member-access chains section for the 2.17.0 support (
a.b.c,a.b?.c, chained writes, parenthesized receivers,(expr).m().field). - Core capabilities gains a null-safety bullet.
- The
null/None/nilrow was✅for Wasm, which overstated it — Wasm has no null value of its own and represents it as a boxed pointer. Now🧩, pointing at the limits. - The Wasm status paragraph mentions the boxed-
nulldomain and the concrete-slot error.
Tests
2492 passing (from 2463). Beyond regressions for both fixes, a new unit test calls both null hooks directly on all nine generators. generateASTValueNull — the resolved-value hook — turned out to be uncovered in every generator including the base, so a wrong spelling there would have gone unnoticed: exactly the class of bug Lua had.