Skip to content

Commit 2bc9676

Browse files
committed
avoid an edge case where a function happens to be the parameter
1 parent b3a896a commit 2bc9676

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

jscomp/core/js_dump.ml

+10-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,16 @@ and pp_function ~return_unit ~is_method cxt (f : P.t) ~fn_state
319319
{[ function(x,y){ return u(x,y) } ]}
320320
it can be optimized in to either [u] or [Curry.__n(u)]
321321
*)
322-
(not is_method) && Ext_list.for_all2_no_exn ls l is_var -> (
322+
(not is_method)
323+
&& Ext_list.for_all2_no_exn ls l is_var
324+
&&
325+
match v with
326+
(* This check is needed to avoid some edge cases
327+
{[function(x){return x(x)}]}
328+
here the function is also called `x`
329+
*)
330+
| Id id -> not (Ext_list.exists l (fun x -> Ident.same x id))
331+
| Qualified _ -> true -> (
323332
let optimize len ~p cxt f v =
324333
if p then try_optimize_curry cxt f len function_id else vident cxt f v
325334
in

0 commit comments

Comments
 (0)