Semantic Diff

#9478 Call instead of inlining a body that names a module the caller can't load

1 commit

66d9f5d8d42b09948f1b1d202c3840391bc16479..pr-9478

3a025b47a · cknitt + Claude · Nov 29, 2026, 07:52 UTC

Call instead of inlining a body that names a module the caller can't load

Why

A body stored in a .cmj can name modules of packages its own package depends on. A package depending on that one usually does not have them on its load path, so inlining the body failed the build. This is PR 4 of the plan in #8733 (problem 2.9).

modifiedJS with -bs-cross-module-opt; app depends on p, p on q

// node_modules/p/src/PMod.res@inline let f = x => QMod.g(x) + 1@inline let k = x => x * 2 // app/src/App.reslet viaQ = PMod.f(2)let local = PMod.k(2)
diagnostic
Before
QMod not found, it means either the module does not exist or it is a namespace
js
After app/src/App.mjs
import * as PMod from "p/src/PMod.mjs"; let viaQ = PMod.f(2); let local = 4;

Review

  • Does looking a module up change the imports? No. The check reads this compile's module cache and the load path, and does not register the module, since registered modules with side effects get imported.