Skip to content

Commit fc38b25

Browse files
committed
More selective fix for lam_pass_remove_alias
1 parent a1e7cc5 commit fc38b25

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

compiler/core/lam_pass_remove_alias.ml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,23 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
4545
let rec simpl (lam : Lam.t) : Lam.t =
4646
match lam with
4747
| Lvar _ -> lam
48+
(* 7432: prevent optimization in JSX preserve mode *)
49+
| Lprim
50+
{
51+
primitive = Pjs_call {prim_name = "jsx" | "jsxs"} as primitive;
52+
args = (Lprim {primitive = Pfield (_, _)} as field_arg) :: rest;
53+
loc;
54+
}
55+
when !Js_config.jsx_preserve ->
56+
Lam.prim ~primitive ~args:(field_arg :: Ext_list.map rest simpl) loc
4857
| Lprim {primitive = Pfield (i, info) as primitive; args = [arg]; loc} -> (
4958
(* ATTENTION:
5059
Main use case, we should detect inline all immutable block .. *)
5160
match simpl arg with
5261
| Lvar v as l ->
53-
(* Preserve module qualification when JSX preserve mode is enabled
54-
This ensures component names like X.make are not flattened to just make
55-
in JSX preserve mode *)
56-
let prim = Lam.prim ~primitive ~args:[l] loc in
57-
if !Js_config.jsx_preserve then prim
58-
else Lam_util.field_flatten_get (fun _ -> prim) v i info meta.ident_tbl
62+
Lam_util.field_flatten_get
63+
(fun _ -> Lam.prim ~primitive ~args:[l] loc)
64+
v i info meta.ident_tbl
5965
| l -> Lam.prim ~primitive ~args:[l] loc)
6066
| Lprim
6167
{

0 commit comments

Comments
 (0)