Repository navigation
Conversation
Why:
A function body stored in a .cmj for other modules to inline kept the
locations of its applications, primitives and functions, and
-no-keep-locs does not cover them. So with -bs-cross-module-opt a line
shift changed the .cmj, and the runtime's published .cmj files held the
absolute paths of the machine that built them. Rebuilding dependents when
a .cmj changes (#8733, PR 2) would then rebuild them on every line shift.
Nothing reads these locations once the body is inlined elsewhere.
Cmj modified (stored body):
Example:
// A.res, compiled with -bs-cross-module-opt, then again with a blank
// line added at the top
@inline let g = x => x + 1
let h = x => x * 2
let flag = true
Before (text):
A.cmj: 200 bytes, names /…/A.res
after the line shift: A.cmj changes
After (text):
A.cmj: 170 bytes, names no file
after the line shift: A.cmj is byte for byte the same
Review: Does inlining change? No. A dependent's JS is the same, and so is
the runtime's and Belt's.
Review: Why build through Lambda's constructors? The rest of
Lambda_traverse does, so a stored body is normalized like any other term.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gJwNt3jmNq5d8xKA9D
Signed-off-by: Christoph Knittel <ck@cca.io>
Changelog🏠 Internal
Semantic Diff1 commit · Full page Leave source locations out of bodies stored in .cmj files7b26dcc · cknitt + Claude · Nov 28, 2026, 20:48 UTC
Cmj modified (stored body) // A.res, compiled with -bs-cross-module-opt, then again with a blank
// line added at the top
@inline let g = x => x + 1
let h = x => x * 2
let flag = true
-A.cmj: 200 bytes, names /…/A.res
-after the line shift: A.cmj changes
+A.cmj: 170 bytes, names no file
+after the line shift: A.cmj is byte for byte the sameReview
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9470 +/- ##
=======================================
Coverage 82.34% 82.35%
=======================================
Files 462 462
Lines 65817 65843 +26
=======================================
+ Hits 54198 54222 +24
- Misses 11619 11621 +2
🚀 New features to boost your workflow:
|
🎉 Compiler benchmarksAllocated wordsIn total: 656,997,638 → 656,987,142 (±0.00%). Generated projects: 629,285,350 → 629,285,160 (±0.00%). None of the 265 benchmarks changed by 0.1% or more. InstructionsIn total: 9,223,996,068 → 9,224,178,313 (±0.00%). None of the 33 benchmarks changed by 0.1% or more. Output sizeIn total: 26,710,059 → 26,696,844 (-0.05%). 🎉 Improvement: 2 outputs are more than 1% smaller.
Pull request 7b26dcc compared with base e51ee46 in this run. |
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9470 |
Function bodies stored in a
.cmjfor other modules to inline no longer keep source locations. This is PR 1 of the plan in #8733 (problem 2.10).Before, a stored body kept the locations of its applications, primitives and functions, and
-no-keep-locsdoesn't cover them. With-bs-cross-module-opt, which the runtime and Belt are built with, that meant:.cmj;.cmjfiles contained the absolute paths of the machine that built them.The next PR in the plan rebuilds dependents when a
.cmjchanges. Without this one, it would rebuild the direct dependents of a module with a.resion every line shift. Nothing reads these locations once a body is inlined in another module.The new
Lambda_traverse.drop_locationssets every location toLocation.none, building throughLambda's constructors like the rest of that module. Generated JavaScript doesn't change, for the runtime, Belt or the test suite.New tests: two cases in
ounit_lambda_traverse_tests.ml. One checks that a term with locations under nodes without them comes back with none. The other checks that a term without locations is handed back as it is.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gJwNt3jmNq5d8xKA9D