Skip to content

Commit b643d96

Browse files
committed
Compiler: fix sourcemap merging
1 parent 61d898d commit b643d96

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

compiler/lib/source_map.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ let string_of_mapping mapping =
104104
let l =
105105
(c.gen_col - !gen_col)
106106
::
107-
(if c.ori_source = -1
107+
(if c.ori_source < 0
108108
then []
109109
else
110110
(c.ori_source - !ori_source)
@@ -119,7 +119,7 @@ let string_of_mapping mapping =
119119
[ n - n' ]))
120120
in
121121
gen_col := c.gen_col;
122-
if c.ori_source <> -1
122+
if c.ori_source >= 0
123123
then (
124124
ori_source := c.ori_source;
125125
ori_line := c.ori_line;
@@ -199,7 +199,9 @@ let mapping_of_string str =
199199

200200
let maps ~sources_offset ~names_offset x =
201201
let gen_line = x.gen_line in
202-
let ori_source = x.ori_source + sources_offset in
202+
let ori_source =
203+
if x.ori_source < 0 then x.ori_source else x.ori_source + sources_offset
204+
in
203205
let ori_name =
204206
match x.ori_name with
205207
| None -> None

compiler/tests-sourcemap/dump.reference

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ b.ml:1:10 -> 17: function f(x){<>return x - 1 | 0;}
55
b.ml:1:6 -> 24: function f(x){return <>x - 1 | 0;}
66
b.ml:1:15 -> 34: function f(x){return x - 1 | 0;<>}
77
b.ml:1:4 -> 23: var Testlib_B = [0, <>f];
8-
d.ml:-1:-1 -> 2: <>}
9-
a.ml:-1:-1 -> 3: <>function caml_call1(f, a0){
10-
a.ml:-1:-1 -> 2: <>}

0 commit comments

Comments
 (0)