Skip to content

Commit 9f20509

Browse files
authored
Merge pull request #1070 from bloomberg/fix_gpr_977
fix #977, add unit tests
2 parents 6cd086a + 5394da1 commit 9f20509

25 files changed

+155
-43
lines changed

jscomp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BYTE=ocamlc.opt$(EXE)
1010
OCAMLLEX=ocamllex.opt$(EXE)
1111
CAMLP4OF=camlp4of
1212
CAMLDEP=ocamldep.opt$(EXE)
13-
COMPFLAGS= -g -w +6-40-30-23 -warn-error +a-40-30-23
13+
COMPFLAGS= -g -w +6-40-30-23 -warn-error +a-40-30-23
1414

1515

1616
.SUFFIXES: .mli .ml .cmi .cmx .mll .c .o .cmo

jscomp/bin/all_ounit_tests.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ end = struct
13421342

13431343

13441344
let reverse_range a i len =
1345-
if len=0 then ()
1345+
if len = 0 then ()
13461346
else
13471347
for k = 0 to (len-1)/2 do
13481348
let t = Array.unsafe_get a (i+k) in
@@ -1549,7 +1549,7 @@ external char_code: char -> int = "%identity"
15491549
external char_chr: int -> char = "%identity"
15501550

15511551
let escaped s =
1552-
let n = ref 0 in
1552+
let n = Pervasives.ref 0 in
15531553
for i = 0 to Bytes.length s - 1 do
15541554
n := !n +
15551555
(match Bytes.unsafe_get s i with

jscomp/bin/bsb.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ external char_code: char -> int = "%identity"
335335
external char_chr: int -> char = "%identity"
336336

337337
let escaped s =
338-
let n = ref 0 in
338+
let n = Pervasives.ref 0 in
339339
for i = 0 to Bytes.length s - 1 do
340340
n := !n +
341341
(match Bytes.unsafe_get s i with
@@ -2813,7 +2813,7 @@ end = struct
28132813

28142814

28152815
let reverse_range a i len =
2816-
if len=0 then ()
2816+
if len = 0 then ()
28172817
else
28182818
for k = 0 to (len-1)/2 do
28192819
let t = Array.unsafe_get a (i+k) in
@@ -4573,7 +4573,7 @@ module Ext_file_pp : sig
45734573
type action =
45744574
[
45754575
`skip
4576-
| `print of (out_channel -> int -> unit)
4576+
| `print of (Pervasives.out_channel -> int -> unit)
45774577
]
45784578

45794579

jscomp/bin/bsb_helper.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ external char_code: char -> int = "%identity"
301301
external char_chr: int -> char = "%identity"
302302

303303
let escaped s =
304-
let n = ref 0 in
304+
let n = Pervasives.ref 0 in
305305
for i = 0 to Bytes.length s - 1 do
306306
n := !n +
307307
(match Bytes.unsafe_get s i with

jscomp/bin/bsdep.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23127,7 +23127,7 @@ external char_code: char -> int = "%identity"
2312723127
external char_chr: int -> char = "%identity"
2312823128

2312923129
let escaped s =
23130-
let n = ref 0 in
23130+
let n = Pervasives.ref 0 in
2313123131
for i = 0 to Bytes.length s - 1 do
2313223132
n := !n +
2313323133
(match Bytes.unsafe_get s i with

jscomp/bin/bsppx.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4974,7 +4974,7 @@ external char_code: char -> int = "%identity"
49744974
external char_chr: int -> char = "%identity"
49754975

49764976
let escaped s =
4977-
let n = ref 0 in
4977+
let n = Pervasives.ref 0 in
49784978
for i = 0 to Bytes.length s - 1 do
49794979
n := !n +
49804980
(match Bytes.unsafe_get s i with

jscomp/bin/whole_compiler.ml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20942,7 +20942,7 @@ external char_code: char -> int = "%identity"
2094220942
external char_chr: int -> char = "%identity"
2094320943

2094420944
let escaped s =
20945-
let n = ref 0 in
20945+
let n = Pervasives.ref 0 in
2094620946
for i = 0 to Bytes.length s - 1 do
2094720947
n := !n +
2094820948
(match Bytes.unsafe_get s i with
@@ -57204,7 +57204,7 @@ end = struct
5720457204

5720557205

5720657206
let reverse_range a i len =
57207-
if len=0 then ()
57207+
if len = 0 then ()
5720857208
else
5720957209
for k = 0 to (len-1)/2 do
5721057210
let t = Array.unsafe_get a (i+k) in
@@ -91657,6 +91657,13 @@ let translate loc
9165791657
| [ e ] -> E.int32_minus (E.zero_int_literal) e
9165891658
| _ -> assert false
9165991659
end
91660+
| Pnegint
91661+
->
91662+
begin match args with (* #977 *)
91663+
| [ e ] -> E.int32_minus (E.zero_int_literal) e
91664+
| _ -> assert false
91665+
end
91666+
9166091667
| Pnegbint Pnativeint
9166191668
->
9166291669
begin match args with
@@ -91667,13 +91674,7 @@ let translate loc
9166791674
->
9166891675
Js_long.neg args
9166991676

91670-
| Pnegint
91671-
->
91672-
begin match args with
91673-
| [ e ] -> E.unchecked_int32_minus (E.zero_int_literal) e
91674-
| _ -> assert false
91675-
end
91676-
91677+
9167791678
| Pnegfloat
9167891679
->
9167991680
begin match args with

jscomp/core/lam_compile_group.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ let lambda_as_module
367367
begin
368368
Js_config.set_current_file filename ;
369369
#if BS_DEBUG then
370-
Js_config.set_debug_file "rec_value_test.ml";
370+
Js_config.set_debug_file "gpr_977_test.ml";
371371
#end
372372
let lambda_output = compile ~filename output_prefix env sigs lam in
373373
let (//) = Filename.concat in

jscomp/core/lam_compile_primitive.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ let translate loc
8585
| [ e ] -> E.int32_minus (E.zero_int_literal) e
8686
| _ -> assert false
8787
end
88+
| Pnegint
89+
->
90+
begin match args with (* #977 *)
91+
| [ e ] -> E.int32_minus (E.zero_int_literal) e
92+
| _ -> assert false
93+
end
94+
8895
| Pnegbint Pnativeint
8996
->
9097
begin match args with
@@ -95,13 +102,7 @@ let translate loc
95102
->
96103
Js_long.neg args
97104

98-
| Pnegint
99-
->
100-
begin match args with
101-
| [ e ] -> E.unchecked_int32_minus (E.zero_int_literal) e
102-
| _ -> assert false
103-
end
104-
105+
105106
| Pnegfloat
106107
->
107108
begin match args with

jscomp/ext/ext_array.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
let reverse_range a i len =
30-
if len=0 then ()
30+
if len = 0 then ()
3131
else
3232
for k = 0 to (len-1)/2 do
3333
let t = Array.unsafe_get a (i+k) in

0 commit comments

Comments
 (0)