Skip to content

fix window location regression #5068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions jscomp/core/lam_convert.ml
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
Lam.for_ id (convert_aux from_) (convert_aux to_) dir (convert_aux loop)
| Lassign (id, body) ->
Lam.assign id (convert_aux body)
| Lsend (Public(Some name), _, obj, _, loc) ->
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
| Lsend (Public(Some name), _, obj, meth_args, loc) ->
let obj = convert_aux obj in
let args = [obj] in
let setter = Ext_string.ends_with name Literals.setter_suffix in
Expand All @@ -827,8 +826,11 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
(String.sub name 0
(String.length name - Literals.setter_suffix_len))
else Lam_methname.translate name in
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
~args loc
let new_obj = prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
~args loc in
if meth_args = [] then new_obj
else Lam.apply new_obj
(Ext_list.map meth_args convert_aux) {ap_loc = loc; ap_inlined = Default_inline; ap_status = App_na}

| Lsend _ -> assert false
| Levent _ ->
Expand Down Expand Up @@ -1002,8 +1004,8 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i


we should not remove it immediately, since we have to be careful
where it is used, it can be [exported], [Lvar] or [Lassign] etc
The other common mistake is that
where it is used, it can be [exported], [Lvar] or [Lassign] etc
The other common mistake is that
{[
let x = y (* elimiated x/y*)
let u = x (* eliminated u/x *)
Expand All @@ -1015,11 +1017,11 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
let x = y (* x/y *)
let u = x (* u/y *)
]}
This looks more correct, but lets be conservative here
This looks more correct, but lets be conservative here

global module inclusion {[ include List ]}
will cause code like {[ let include =a Lglobal_module (list)]}
global module inclusion {[ include List ]}
will cause code like {[ let include =a Lglobal_module (list)]}

when [u] is global, it can not be bound again,
it should always be the leaf
when [u] is global, it can not be bound again,
it should always be the leaf
*)
5 changes: 5 additions & 0 deletions jscomp/test/js_obj_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
var Mt = require("./mt.js");
var Curry = require("../../lib/js/curry.js");

function f9($$window) {
return Curry._2($$window.location, 1, 2);
}

function f(u) {
var h = u.say;
return Curry._1(h, 32);
Expand Down Expand Up @@ -80,6 +84,7 @@ var suites = {

Mt.from_pair_suites("Js_obj_test", suites);

exports.f9 = f9;
exports.f = f;
exports.f_js = f_js;
exports.suites = suites;
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/js_obj_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open Js_obj
type x = < say : int -> int >



let f9 window = window#location 1 2

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

Expand Down
6 changes: 4 additions & 2 deletions jscomp/test/res_debug.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';


var u = 0;
function f($$window, a, b) {
return $$window.location(a, b);
}

exports.u = u;
exports.f = f;
/* No side effect */
4 changes: 3 additions & 1 deletion jscomp/test/res_debug.res
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ type t = { x : int, y : int}
// x + y
// }

let u = #0
let f = (window,a,b) => {
window["location"](.a,b)
}
24 changes: 13 additions & 11 deletions lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -393775,8 +393775,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
Lam.for_ id (convert_aux from_) (convert_aux to_) dir (convert_aux loop)
| Lassign (id, body) ->
Lam.assign id (convert_aux body)
| Lsend (Public(Some name), _, obj, _, loc) ->
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
| Lsend (Public(Some name), _, obj, meth_args, loc) ->
let obj = convert_aux obj in
let args = [obj] in
let setter = Ext_string.ends_with name Literals.setter_suffix in
Expand All @@ -393786,8 +393785,11 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
(String.sub name 0
(String.length name - Literals.setter_suffix_len))
else Lam_methname.translate name in
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
~args loc
let new_obj = prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
~args loc in
if meth_args = [] then new_obj
else Lam.apply new_obj
(Ext_list.map meth_args convert_aux) {ap_loc = loc; ap_inlined = Default_inline; ap_status = App_na}

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


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

global module inclusion {[ include List ]}
will cause code like {[ let include =a Lglobal_module (list)]}
global module inclusion {[ include List ]}
will cause code like {[ let include =a Lglobal_module (list)]}

when [u] is global, it can not be bound again,
it should always be the leaf
when [u] is global, it can not be bound again,
it should always be the leaf
*)
end
module Lam_pass_alpha_conversion : sig
Expand Down
24 changes: 13 additions & 11 deletions lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -396977,8 +396977,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
Lam.for_ id (convert_aux from_) (convert_aux to_) dir (convert_aux loop)
| Lassign (id, body) ->
Lam.assign id (convert_aux body)
| Lsend (Public(Some name), _, obj, _, loc) ->
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
| Lsend (Public(Some name), _, obj, meth_args, loc) ->
let obj = convert_aux obj in
let args = [obj] in
let setter = Ext_string.ends_with name Literals.setter_suffix in
Expand All @@ -396988,8 +396987,11 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
(String.sub name 0
(String.length name - Literals.setter_suffix_len))
else Lam_methname.translate name in
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
~args loc
let new_obj = prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
~args loc in
if meth_args = [] then new_obj
else Lam.apply new_obj
(Ext_list.map meth_args convert_aux) {ap_loc = loc; ap_inlined = Default_inline; ap_status = App_na}

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


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

global module inclusion {[ include List ]}
will cause code like {[ let include =a Lglobal_module (list)]}
global module inclusion {[ include List ]}
will cause code like {[ let include =a Lglobal_module (list)]}

when [u] is global, it can not be bound again,
it should always be the leaf
when [u] is global, it can not be bound again,
it should always be the leaf
*)
end
module Lam_pass_alpha_conversion : sig
Expand Down