Semantic Diff

#9343 Reject unit arguments of @set, @set_index and @get_index externals

2 commits

91d74a0eb09e3a7cc0bba0793b14fbab5cd21bcd..pr-9343

1ce26e02f · cknitt + Claude · Nov 19, 2026, 19:12 UTC

Reject unit arguments of @set, @set_index and @get_index externals

Why

A unit argument is left out of the JS code, so the compiler crashed with an assertion failure when it built the property access without its object, index or value (#9339). @get already rejected it.

addedDiagnostic unit argument of a property external

type t@set external setX: (t, unit) => unit = "x"
diagnostic
Before
After
Fatal error: exception File "compiler/core/lam_compile_external_call.ml", line 448, characters 11-17: Assertion failedIll defined attribute @set (unit argument is not allowed)

Fixes #9339

Review

  • Can such an external be useful? No. It would set or read a property with a part missing. Declaring one now fails even when it is never called; before, only a call crashed.
8bdca68e6 · cknitt + Claude · Nov 19, 2026, 19:27 UTC

Accept property externals whose arguments are all constants

Why

When every argument is an @as constant, a unit parameter is added after the arguments so the external stays callable. The new unit check also saw that parameter, so it rejected valid externals such as @get external readX: @as(json{"x":1}) _ => int = "x". The checks now look at the declared arguments only.