Skip to content

v2.21.0 - Document the null-safety surface; fix Kotlin `?[` and Lua `null`

Choose a tag to compare

@gmpassos gmpassos released this 25 Jul 02:56
· 108 commits to master since this release
a7a034c

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 ⚠️ lossy marker, distinguishing three previously-conflated situations:

  • ✅ native — the target has the operator (Kotlin ?:, TS ?., C# ??).
  • 🧩 idiom — a faithful desugaring (Java's ternary for ??, Lua's IIFE with an explicit nil test, 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 call xs?.get(0). The shared nullAwareIndexOpen hook gained a matching nullAwareIndexClose, so a target can close with ) instead of ].
  • Lua's null literal was null. Lua's is nil, so the generated source referenced an undefined global and a == null was 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 / nil row 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-null domain 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.