Skip to content

Commit c64f7ff

Browse files
authored
Merge pull request #3873 from BuckleScript/fix_3865
tentative fix for #3865
2 parents 0bfddc5 + fcf002b commit c64f7ff

37 files changed

+1278
-440
lines changed

jscomp/core/js_dump.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,8 @@ and expression_desc cxt (level:int) f x : cxt =
854854
else
855855
E.runtime_call Js_runtime_modules.option "some" [e])
856856
| Caml_block(el,_, _, Blk_module fields) ->
857-
expression_desc cxt (level:int) f (Object (List.combine fields el))
857+
expression_desc cxt (level:int) f (Object (
858+
(Ext_list.map_combine fields el Ext_ident.convert)))
858859
| Caml_block( el, mutable_flag, tag, tag_info)
859860
->
860861
(* Note that, if we ignore more than tag [0] we loose some information

jscomp/core/js_exp_make.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ let dot ?comment (e0 : t) (e1 : string) : t =
163163

164164

165165
let module_access (e : t) (name : string) (pos : int32) =
166+
let name = Ext_ident.convert name in
166167
match e.expression_desc with
167168
| Caml_block (l, _, _,_) when no_side_effect e ->
168169
(match Ext_list.nth_opt l (Int32.to_int pos) with

jscomp/ext/ext_list.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ let rec has_string l f =
6868
| x1 :: x2 :: x3 :: x4 ->
6969
x1 = f || x2 = f || x3 = f || has_string x4 f
7070

71+
let rec map_combine l1 l2 f =
72+
match (l1, l2) with
73+
([], []) -> []
74+
| (a1::l1, a2::l2) ->
75+
(f a1, a2) :: map_combine l1 l2 f
76+
| (_, _) ->
77+
invalid_arg "Ext_list.map_combine"
7178

7279
let rec map_split_opt
7380
(xs : 'a list) (f : 'a -> 'b option * 'c option)

jscomp/ext/ext_list.mli

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,18 @@ val map :
2828
('a -> 'b) ->
2929
'b list
3030

31+
val map_combine :
32+
'a list ->
33+
'b list ->
34+
('a -> 'c) ->
35+
('c * 'b) list
36+
3137
val has_string :
3238
string list ->
3339
string ->
3440
bool
41+
42+
3543
val map_split_opt :
3644
'a list ->
3745
('a -> 'b option * 'c option) ->

jscomp/test/basic_module_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ var Mt_global = require("./mt_global.js");
99
var count = /* record */[/* contents */0];
1010

1111
var M = {
12-
Set: Offset.M.Set
12+
$$Set: Offset.M.$$Set
1313
};
1414

1515
function test(set) {
16-
count[0] = Curry._1(M.Set.cardinal, set) + count[0] | 0;
16+
count[0] = Curry._1(M.$$Set.cardinal, set) + count[0] | 0;
1717
return /* () */0;
1818
}
1919

20-
test(Curry._1(Offset.M.Set.singleton, "42"));
20+
test(Curry._1(Offset.M.$$Set.singleton, "42"));
2121

2222
var suites = /* record */[/* contents : [] */0];
2323

jscomp/test/build.ninja

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ build test/gpr_3609_test.cmi test/gpr_3609_test.cmj : cc test/gpr_3609_test.ml |
297297
build test/gpr_3697_test.cmi test/gpr_3697_test.cmj : cc test/gpr_3697_test.ml | $stdlib
298298
build test/gpr_373_test.cmi test/gpr_373_test.cmj : cc test/gpr_373_test.ml | $stdlib
299299
build test/gpr_3770_test.cmi test/gpr_3770_test.cmj : cc test/gpr_3770_test.ml | $stdlib
300+
build test/gpr_3865.cmi test/gpr_3865.cmj : cc test/gpr_3865.re | test/gpr_3865_bar.cmj test/gpr_3865_foo.cmj $stdlib
301+
build test/gpr_3865_bar.cmi test/gpr_3865_bar.cmj : cc test/gpr_3865_bar.re | $stdlib
302+
build test/gpr_3865_foo.cmi test/gpr_3865_foo.cmj : cc test/gpr_3865_foo.re | $stdlib
300303
build test/gpr_405_test.cmj : cc_cmi test/gpr_405_test.ml | test/gpr_405_test.cmi $stdlib
301304
build test/gpr_405_test.cmi : cc test/gpr_405_test.mli | $stdlib
302305
build test/gpr_441.cmi test/gpr_441.cmj : cc test/gpr_441.ml | $stdlib

jscomp/test/class4_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function restricted_point2$prime_init($$class) {
9696
var restricted_point2$prime = CamlinternalOO.make_class(shared$2, restricted_point2$prime_init);
9797

9898
var Point = {
99-
"restricted_point'": restricted_point
99+
restricted_point$prime: restricted_point
100100
};
101101

102102
function abstract_point_001($$class) {

jscomp/test/gpr_3519_jsx_test.js

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

33

44
var React = {
5-
null: /* () */0
5+
$$null: /* () */0
66
};
77

88
function make(param, param$1) {

jscomp/test/gpr_3865.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
var Gpr_3865_foo = require("./gpr_3865_foo.js");
4+
5+
var B = {
6+
$$return: Gpr_3865_foo.$$return
7+
};
8+
9+
console.log(Gpr_3865_foo.$$return);
10+
11+
console.log(Gpr_3865_foo.$$return);
12+
13+
var F = 0;
14+
15+
exports.F = F;
16+
exports.B = B;
17+
/* Not a pure module */

jscomp/test/gpr_3865.re

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module F = Gpr_3865_foo;
2+
module B = Gpr_3865_bar.Make(Gpr_3865_foo);
3+
4+
Js.log(F.return);
5+
Js.log(B.return);

0 commit comments

Comments
 (0)