Emit source map mappings for pattern-match arms, branch tests, and block boundaries
Why
Pattern-match arms and if branches returning a constant or variable (| Empty => "empty", | None => -1, | _ => x) emitted no source map mapping, because Lambda.t carried Location.t only on Lprim, Lapply, and Lfunction. Branch dispatch tests (typeof s !== "object", o === undefined, switch (s.TAG)) and shared destructuring (Primitive_option.valFromOption(o)) either had no mapping or borrowed a sibling arm's location, and block/function closing braces had no end mappings, causing V8 coverage tools (c8 / v8-to-istanbul) to drop unexecuted ranges and report unexecuted arms as covered (#9387).
modifiedSourceMap pattern-match arms and dispatch tests
let opt = o => switch o { | Some(Some(x)) => x + 1 | Some(None) => 0 | None => -1 }
text
Fixes #9387
Review
- Does attaching locations to Lambda branch nodes change optimizations or generated JS? No. Leaf nodes (
Lconst,Lvar) are untouched, andLambda_traverse.make_keyandLambda.eq_approxignore all branch and node locations. Generated JS is byte-identical with source maps enabled or disabled (apart from thesourceMappingURLcomment). - How are non-1:1 arm optimizations (merged, split, or reordered branches) handled? Shared destructuring (
relocate_cell_args) and dispatch tests map to the enclosingswitch/ifrather than a sibling arm. Fallthroughcaselabels keep each arm'spat_loc, inlined static exits (Lam_pass_exits) propagatebranch_locto every inlined site, and same-switch nested dispatch blocks (if (typeof s !== "object")) map{and}toswitchstart so interleaved executed arms are never marked uncovered.