Skip to content

WIP: no sugar needed for message sending #4968

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

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 17 additions & 3 deletions jscomp/core/lam_convert.ml
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,8 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
| Lassign (id, body) ->
Lam.assign id (convert_aux body)
| Lsend (kind, _,b,ls, _loc) ->
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
(* we should add Pjs_* to any send, so that the preprocessing is not needed any more
*)
(match convert_aux b with
| Lprim {primitive = Pjs_unsafe_downgrade {loc}; args}
->
Expand All @@ -834,8 +835,21 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
~args loc
| _ -> assert false
end
| _ ->
assert false)
| obj ->
begin match kind, ls with
| Public (Some name), [] ->
let setter = Ext_string.ends_with name Literals.setter_suffix in
let property =
if setter then
Lam_methname.translate
(String.sub name 0
(String.length name - Literals.setter_suffix_len))
else Lam_methname.translate name in
prim ~primitive:(Pjs_unsafe_downgrade {name = property;loc=_loc; setter})
~args:[obj] _loc
| _ -> assert false
end
)

| Levent _ ->
(* disabled by upstream*)
Expand Down
4 changes: 2 additions & 2 deletions jscomp/frontend/bs_ast_invariant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ let emit_external_warnings : iterator=
| Pexp_new _ ->
Location.raise_errorf ~loc:a.pexp_loc
"OCaml style objects are not supported"
| Pexp_send (obj, _) ->
(* | Pexp_send (obj, _) ->
begin match obj with
| {pexp_desc = Pexp_apply ({pexp_desc = Pexp_ident ({txt = Ldot(_,"unsafe_downgrade")})},_)} -> ()
| _ -> Location.raise_errorf ~loc:a.pexp_loc
"OCaml style objects are not supported"
end
end *)
| _ -> super.expr self a
);
label_declaration = (fun self lbl ->
Expand Down
13 changes: 12 additions & 1 deletion jscomp/test/debug_tmp.js
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
'use strict';


function u(x) {
return [
x.hi,
x.yo
];
}

exports.u = u;
/* No side effect */
2 changes: 2 additions & 0 deletions jscomp/test/debug_tmp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
|]
}]


let u x = x#hi,x#yo