Semantic Diff

#9537 Inline other modules' functions only in the alias pass

1 commit

97f2861b26950e10a3a5cef32d8abfe6ffbc1a97..pr-9537

de87d9af6 · cknitt + Claude · Dec 05, 2026, 10:00 UTC

Inline other modules' functions only in the alias pass

Why

A call to another module's @inline function could be inlined in two places: early by the alias pass, and late while compiling to JavaScript. The late copy skipped every Lambda pass, so it kept what those passes remove, and it was inlined into a function whose refs were already assigned variables. Since the alias pass now inlines calls with parameters as arguments, the late path only gets calls through an alias, such as add from let {add} = module(List). These are now compiled as calls, until the alias pass learns to see through them. The call no longer looks up the other module's .cmj: the late path needed its stored body, and the name it returned is the field name the call already has. The backend guide gets a section on the Lambda pipeline, with its single cross-module inlining phase.

modifiedJS a call through an alias

let {length: l, add} = module(List)let r = list{}->add(l(list{1, 2, 3}))
js
Before
After
let r_0 = Stdlib_List.length({hd: 1, tl: {hd: 2, tl: {hd: 3, tl: /* [] */0}}}); let r = {hd: r_0, tl: /* [] */0};let r = Stdlib_List.add(/* [] */0, Stdlib_List.length({hd: 1, tl: {hd: 2, tl: {hd: 3, tl: /* [] */0}}}));

Review

  • What do the new tests cover? inline_late_alias_test has the cases that broke when a late body was simplified: functions reading a let-bound global, a known tuple or an assigned ref, Somes of known values, and refs of the caller assigned by a callback. The alias pass inlines all of them now.