Skip to content

Commit 6530bdb

Browse files
authored
Merge pull request #1558 from bloomberg/fix_1556
fix #1556
2 parents ebb555b + edb57d4 commit 6530bdb

10 files changed

+90
-64
lines changed

Changes

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
3+
BuckleScript 1.7.2:
4+
==================
5+
6+
Bug fixes:
7+
8+
- #1556, fix duplicated requires of runtime (report by Chenglou)
9+
10+

jscomp/bin/whole_compiler.ml

+40-28
Original file line numberDiff line numberDiff line change
@@ -65318,35 +65318,47 @@ let name x : string =
6531865318
| Ml | Runtime -> x.id.name
6531965319
| External v -> v
6532065320

65321-
let equal (x : t) y =
65322-
match x.kind with
65323-
| External x_kind->
65324-
begin match y.kind with
65325-
| External y_kind ->
65326-
x_kind = (y_kind : string)
65327-
| _ -> false
65328-
end
65329-
| Ml -> y.kind = Ml && Ext_ident.equal x.id y.id
65330-
| Runtime ->
65331-
y.kind = Runtime && Ext_ident.equal x.id y.id
65332-
let hash (x : t) =
65333-
match x.kind with
65334-
| External x_kind -> Bs_hash_stubs.hash_string x_kind
65335-
| Ml | Runtime ->
65336-
let x_id = x.id in
65337-
Bs_hash_stubs.hash_stamp_and_name x_id.stamp x_id.name
65338-
65339-
module Hash = Hashtbl_make.Make(struct
65340-
type nonrec t = t
65341-
let hash = hash
65342-
let equal = equal
65343-
end)
65321+
module Cmp = struct
65322+
type nonrec t = t
65323+
let equal (x : t) y =
65324+
match x.kind with
65325+
| External x_kind->
65326+
begin match y.kind with
65327+
| External y_kind ->
65328+
x_kind = (y_kind : string)
65329+
| _ -> false
65330+
end
65331+
| Ml
65332+
| Runtime -> Ext_ident.equal x.id y.id
65333+
(* #1556
65334+
Note the main difference between [Ml] and [Runtime] is
65335+
that we have more assumptions about [Runtime] module,
65336+
like its purity etc, and its name uniqueues, in the pattern match
65337+
{[
65338+
Qualified (_,Runtime, Some "caml_int_compare")
65339+
]}
65340+
and we could do more optimziations.
65341+
However, here if it is [hit]
65342+
(an Ml module = an Runtime module), which means both exists,
65343+
so adding either does not matter
65344+
if it is not hit, fine
65345+
*)
65346+
(* | Ml -> y.kind = Ml && *)
65347+
(* | Runtime -> *)
65348+
(* y.kind = Runtime && Ext_ident.equal x.id y.id *)
65349+
let hash (x : t) =
65350+
match x.kind with
65351+
| External x_kind -> Bs_hash_stubs.hash_string x_kind
65352+
| Ml
65353+
| Runtime ->
65354+
let x_id = x.id in
65355+
Bs_hash_stubs.hash_stamp_and_name x_id.stamp x_id.name
65356+
end
65357+
65358+
module Hash = Hashtbl_make.Make (Cmp)
65359+
65360+
module Hash_set = Hash_set.Make (Cmp)
6534465361

65345-
module Hash_set = Hash_set.Make( struct
65346-
type nonrec t = t
65347-
let hash = hash
65348-
let equal = equal
65349-
end)
6535065362
end
6535165363
module Ocaml_stdlib_slots
6535265364
= struct

jscomp/core/lam_module_ident.ml

+40-29
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,43 @@ let name x : string =
5050
| Ml | Runtime -> x.id.name
5151
| External v -> v
5252

53-
let equal (x : t) y =
54-
match x.kind with
55-
| External x_kind->
56-
begin match y.kind with
57-
| External y_kind ->
58-
x_kind = (y_kind : string)
59-
| _ -> false
60-
end
61-
| Ml -> y.kind = Ml && Ext_ident.equal x.id y.id
62-
| Runtime ->
63-
y.kind = Runtime && Ext_ident.equal x.id y.id
64-
let hash (x : t) =
65-
match x.kind with
66-
| External x_kind -> Bs_hash_stubs.hash_string x_kind
67-
| Ml | Runtime ->
68-
let x_id = x.id in
69-
Bs_hash_stubs.hash_stamp_and_name x_id.stamp x_id.name
70-
71-
module Hash = Hashtbl_make.Make(struct
72-
type nonrec t = t
73-
let hash = hash
74-
let equal = equal
75-
end)
76-
77-
module Hash_set = Hash_set.Make( struct
78-
type nonrec t = t
79-
let hash = hash
80-
let equal = equal
81-
end)
53+
module Cmp = struct
54+
type nonrec t = t
55+
let equal (x : t) y =
56+
match x.kind with
57+
| External x_kind->
58+
begin match y.kind with
59+
| External y_kind ->
60+
x_kind = (y_kind : string)
61+
| _ -> false
62+
end
63+
| Ml
64+
| Runtime -> Ext_ident.equal x.id y.id
65+
(* #1556
66+
Note the main difference between [Ml] and [Runtime] is
67+
that we have more assumptions about [Runtime] module,
68+
like its purity etc, and its name uniqueues, in the pattern match
69+
{[
70+
Qualified (_,Runtime, Some "caml_int_compare")
71+
]}
72+
and we could do more optimziations.
73+
However, here if it is [hit]
74+
(an Ml module = an Runtime module), which means both exists,
75+
so adding either does not matter
76+
if it is not hit, fine
77+
*)
78+
(* | Ml -> y.kind = Ml && *)
79+
(* | Runtime -> *)
80+
(* y.kind = Runtime && Ext_ident.equal x.id y.id *)
81+
let hash (x : t) =
82+
match x.kind with
83+
| External x_kind -> Bs_hash_stubs.hash_string x_kind
84+
| Ml
85+
| Runtime ->
86+
let x_id = x.id in
87+
Bs_hash_stubs.hash_stamp_and_name x_id.stamp x_id.name
88+
end
89+
90+
module Hash = Hashtbl_make.Make (Cmp)
91+
92+
module Hash_set = Hash_set.Make (Cmp)

jscomp/test/custom_error_test.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
var Js_exn = require("../../lib/js/js_exn.js");
43
var Js_exn = require("../../lib/js/js_exn.js");
54
var Js_primitive = require("../../lib/js/js_primitive.js");
65

jscomp/test/exception_raise_test.js

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var Mt = require("./mt.js");
44
var Block = require("../../lib/js/block.js");
55
var Curry = require("../../lib/js/curry.js");
66
var Js_exn = require("../../lib/js/js_exn.js");
7-
var Js_exn = require("../../lib/js/js_exn.js");
87
var Caml_exceptions = require("../../lib/js/caml_exceptions.js");
98
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
109

jscomp/test/exception_value_test.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
var Curry = require("../../lib/js/curry.js");
44
var Js_exn = require("../../lib/js/js_exn.js");
5-
var Js_exn = require("../../lib/js/js_exn.js");
65
var Js_primitive = require("../../lib/js/js_primitive.js");
76
var Caml_exceptions = require("../../lib/js/caml_exceptions.js");
87
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");

jscomp/test/exn_error_pattern.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
var Caml_exceptions = require("../../lib/js/caml_exceptions.js");
43
var Caml_exceptions = require("../../lib/js/caml_exceptions.js");
54
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
65

jscomp/test/js_exception_catch_test.js

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var Mt = require("./mt.js");
44
var Block = require("../../lib/js/block.js");
55
var Curry = require("../../lib/js/curry.js");
66
var Js_exn = require("../../lib/js/js_exn.js");
7-
var Js_exn = require("../../lib/js/js_exn.js");
87
var Caml_exceptions = require("../../lib/js/caml_exceptions.js");
98
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
109

jscomp/test/string_runtime_test.js

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ var List = require("../../lib/js/list.js");
55
var Block = require("../../lib/js/block.js");
66
var Bytes = require("../../lib/js/bytes.js");
77
var Caml_string = require("../../lib/js/caml_string.js");
8-
var Caml_string = require("../../lib/js/caml_string.js");
98

109
var suites_000 = /* tuple */[
1110
"string_of_char_array",

lib/js/js_exn.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
var Caml_exceptions = require("./caml_exceptions.js");
43
var Caml_exceptions = require("./caml_exceptions.js");
54

65
var $$Error = Caml_exceptions.create("Js_exn.Error");

0 commit comments

Comments
 (0)