Merge null and undefined checks with source maps on too
Why
With source maps on, the two reads of e in e === null || e === undefined carry different source locations. Js_dump compared them with =, which includes the locations, so it printed both checks instead of e == null, and the JavaScript depended on whether source maps were on. It now compares them with Js_analyzer.eq_expression, which ignores locations. Fixes #9502.
modifiedJS null and undefined checks with source maps
let r = opaque({v: Nullable.null})eq(__LOC__, r.v === Nullable.null || r.v === Nullable.undefined, true)
js
Before tests/compiler_tests/src/null_check_merge_test.res, with source maps
After with source maps, the same as without them
Test_utils.eq("…", r.v === null || r.v === undefined, true);Test_utils.eq("…", r.v == null, true);
Review
- Can
eq_expressionstop a merge that=allowed? It answers false for some shapes, such as floats orLength. Building tests/compiler_tests without source maps gives the committed output, so no merge there is lost.