Skip to content

Commit d5d46b3

Browse files
authored
Merge pull request #5068 from rescript-lang/fix_regression
2 parents be05c58 + 325e674 commit d5d46b3

File tree

7 files changed

+52
-37
lines changed

7 files changed

+52
-37
lines changed

jscomp/core/lam_convert.ml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
816816
Lam.for_ id (convert_aux from_) (convert_aux to_) dir (convert_aux loop)
817817
| Lassign (id, body) ->
818818
Lam.assign id (convert_aux body)
819-
| Lsend (Public(Some name), _, obj, _, loc) ->
820-
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
819+
| Lsend (Public(Some name), _, obj, meth_args, loc) ->
821820
let obj = convert_aux obj in
822821
let args = [obj] in
823822
let setter = Ext_string.ends_with name Literals.setter_suffix in
@@ -827,8 +826,11 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
827826
(String.sub name 0
828827
(String.length name - Literals.setter_suffix_len))
829828
else Lam_methname.translate name in
830-
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
831-
~args loc
829+
let new_obj = prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
830+
~args loc in
831+
if meth_args = [] then new_obj
832+
else Lam.apply new_obj
833+
(Ext_list.map meth_args convert_aux) {ap_loc = loc; ap_inlined = Default_inline; ap_status = App_na}
832834

833835
| Lsend _ -> assert false
834836
| Levent _ ->
@@ -1002,8 +1004,8 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
10021004
10031005
10041006
we should not remove it immediately, since we have to be careful
1005-
where it is used, it can be [exported], [Lvar] or [Lassign] etc
1006-
The other common mistake is that
1007+
where it is used, it can be [exported], [Lvar] or [Lassign] etc
1008+
The other common mistake is that
10071009
{[
10081010
let x = y (* elimiated x/y*)
10091011
let u = x (* eliminated u/x *)
@@ -1015,11 +1017,11 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
10151017
let x = y (* x/y *)
10161018
let u = x (* u/y *)
10171019
]}
1018-
This looks more correct, but lets be conservative here
1020+
This looks more correct, but lets be conservative here
10191021
1020-
global module inclusion {[ include List ]}
1021-
will cause code like {[ let include =a Lglobal_module (list)]}
1022+
global module inclusion {[ include List ]}
1023+
will cause code like {[ let include =a Lglobal_module (list)]}
10221024
1023-
when [u] is global, it can not be bound again,
1024-
it should always be the leaf
1025+
when [u] is global, it can not be bound again,
1026+
it should always be the leaf
10251027
*)

jscomp/test/js_obj_test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
var Mt = require("./mt.js");
44
var Curry = require("../../lib/js/curry.js");
55

6+
function f9($$window) {
7+
return Curry._2($$window.location, 1, 2);
8+
}
9+
610
function f(u) {
711
var h = u.say;
812
return Curry._1(h, 32);
@@ -80,6 +84,7 @@ var suites = {
8084

8185
Mt.from_pair_suites("Js_obj_test", suites);
8286

87+
exports.f9 = f9;
8388
exports.f = f;
8489
exports.f_js = f_js;
8590
exports.suites = suites;

jscomp/test/js_obj_test.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ open Js_obj
44
type x = < say : int -> int >
55

66

7-
7+
let f9 window = window#location 1 2
88

99
let f (u : x ) = let h = u ## say in h 32
1010

jscomp/test/res_debug.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

33

4-
var u = 0;
4+
function f($$window, a, b) {
5+
return $$window.location(a, b);
6+
}
57

6-
exports.u = u;
8+
exports.f = f;
79
/* No side effect */

jscomp/test/res_debug.res

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ type t = { x : int, y : int}
1616
// x + y
1717
// }
1818

19-
let u = #0
19+
let f = (window,a,b) => {
20+
window["location"](.a,b)
21+
}

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393775,8 +393775,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
393775393775
Lam.for_ id (convert_aux from_) (convert_aux to_) dir (convert_aux loop)
393776393776
| Lassign (id, body) ->
393777393777
Lam.assign id (convert_aux body)
393778-
| Lsend (Public(Some name), _, obj, _, loc) ->
393779-
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
393778+
| Lsend (Public(Some name), _, obj, meth_args, loc) ->
393780393779
let obj = convert_aux obj in
393781393780
let args = [obj] in
393782393781
let setter = Ext_string.ends_with name Literals.setter_suffix in
@@ -393786,8 +393785,11 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
393786393785
(String.sub name 0
393787393786
(String.length name - Literals.setter_suffix_len))
393788393787
else Lam_methname.translate name in
393789-
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
393790-
~args loc
393788+
let new_obj = prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
393789+
~args loc in
393790+
if meth_args = [] then new_obj
393791+
else Lam.apply new_obj
393792+
(Ext_list.map meth_args convert_aux) {ap_loc = loc; ap_inlined = Default_inline; ap_status = App_na}
393791393793

393792393794
| Lsend _ -> assert false
393793393795
| Levent _ ->
@@ -393961,8 +393963,8 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
393961393963

393962393964

393963393965
we should not remove it immediately, since we have to be careful
393964-
where it is used, it can be [exported], [Lvar] or [Lassign] etc
393965-
The other common mistake is that
393966+
where it is used, it can be [exported], [Lvar] or [Lassign] etc
393967+
The other common mistake is that
393966393968
{[
393967393969
let x = y (* elimiated x/y*)
393968393970
let u = x (* eliminated u/x *)
@@ -393974,13 +393976,13 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
393974393976
let x = y (* x/y *)
393975393977
let u = x (* u/y *)
393976393978
]}
393977-
This looks more correct, but lets be conservative here
393979+
This looks more correct, but lets be conservative here
393978393980

393979-
global module inclusion {[ include List ]}
393980-
will cause code like {[ let include =a Lglobal_module (list)]}
393981+
global module inclusion {[ include List ]}
393982+
will cause code like {[ let include =a Lglobal_module (list)]}
393981393983

393982-
when [u] is global, it can not be bound again,
393983-
it should always be the leaf
393984+
when [u] is global, it can not be bound again,
393985+
it should always be the leaf
393984393986
*)
393985393987
end
393986393988
module Lam_pass_alpha_conversion : sig

lib/4.06.1/whole_compiler.ml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396977,8 +396977,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
396977396977
Lam.for_ id (convert_aux from_) (convert_aux to_) dir (convert_aux loop)
396978396978
| Lassign (id, body) ->
396979396979
Lam.assign id (convert_aux body)
396980-
| Lsend (Public(Some name), _, obj, _, loc) ->
396981-
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
396980+
| Lsend (Public(Some name), _, obj, meth_args, loc) ->
396982396981
let obj = convert_aux obj in
396983396982
let args = [obj] in
396984396983
let setter = Ext_string.ends_with name Literals.setter_suffix in
@@ -396988,8 +396987,11 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
396988396987
(String.sub name 0
396989396988
(String.length name - Literals.setter_suffix_len))
396990396989
else Lam_methname.translate name in
396991-
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
396992-
~args loc
396990+
let new_obj = prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
396991+
~args loc in
396992+
if meth_args = [] then new_obj
396993+
else Lam.apply new_obj
396994+
(Ext_list.map meth_args convert_aux) {ap_loc = loc; ap_inlined = Default_inline; ap_status = App_na}
396993396995

396994396996
| Lsend _ -> assert false
396995396997
| Levent _ ->
@@ -397163,8 +397165,8 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
397163397165

397164397166

397165397167
we should not remove it immediately, since we have to be careful
397166-
where it is used, it can be [exported], [Lvar] or [Lassign] etc
397167-
The other common mistake is that
397168+
where it is used, it can be [exported], [Lvar] or [Lassign] etc
397169+
The other common mistake is that
397168397170
{[
397169397171
let x = y (* elimiated x/y*)
397170397172
let u = x (* eliminated u/x *)
@@ -397176,13 +397178,13 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
397176397178
let x = y (* x/y *)
397177397179
let u = x (* u/y *)
397178397180
]}
397179-
This looks more correct, but lets be conservative here
397181+
This looks more correct, but lets be conservative here
397180397182

397181-
global module inclusion {[ include List ]}
397182-
will cause code like {[ let include =a Lglobal_module (list)]}
397183+
global module inclusion {[ include List ]}
397184+
will cause code like {[ let include =a Lglobal_module (list)]}
397183397185

397184-
when [u] is global, it can not be bound again,
397185-
it should always be the leaf
397186+
when [u] is global, it can not be bound again,
397187+
it should always be the leaf
397186397188
*)
397187397189
end
397188397190
module Lam_pass_alpha_conversion : sig

0 commit comments

Comments
 (0)