@@ -166,14 +166,6 @@ let exp_need_paren (e : J.expression) =
166166 false
167167 | Await _ -> false
168168
169- let comma_idents (cxt : cxt ) f ls = iter_lst cxt f ls Ext_pp_scope. ident comma
170-
171- let pp_paren_params (inner_cxt : cxt ) (f : Ext_pp.t ) (lexical : Ident.t list ) :
172- unit =
173- P. string f L. lparen;
174- let (_ : cxt ) = comma_idents inner_cxt f lexical in
175- P. string f L. rparen
176-
177169(* * Print as underscore for unused vars, may not be
178170 needed in the future *)
179171(* let ipp_ident cxt f id (un_used : bool) =
@@ -383,10 +375,9 @@ and pp_function ~return_unit ~async ~is_method cxt (f : P.t) ~fn_state
383375 P. space f;
384376 P. brace_vgroup f 1 (fun _ -> function_body ~return_unit cxt f b)
385377 in
386- let lexical : Set_ident.t = Js_fun_env. get_lexical_scope env in
387- let enclose lexical =
388- let handle lexical =
389- if Set_ident. is_empty lexical then (
378+ let enclose () =
379+ let handle () =
380+ (
390381 match fn_state with
391382 | Is_return ->
392383 return_sp f;
@@ -410,46 +401,10 @@ and pp_function ~return_unit ~async ~is_method cxt (f : P.t) ~fn_state
410401 P. space f;
411402 ignore (Ext_pp_scope. ident inner_cxt f x : cxt );
412403 param_body () )
413- else
414- (* print our closure as
415- {[(function(x,y){ return function(..){...}} (x,y))]}
416- Maybe changed to `let` in the future
417- *)
418- let lexical = Set_ident. elements lexical in
419- (match fn_state with
420- | Is_return -> return_sp f
421- | No_name _ -> ()
422- | Name_non_top name | Name_top name ->
423- ignore (pp_var_assign inner_cxt f name : cxt ));
424- if async then P. string f L. await;
425- P. string f L. lparen;
426- P. string f (L. function_async ~async );
427- pp_paren_params inner_cxt f lexical;
428- P. brace_vgroup f 0 (fun _ ->
429- return_sp f;
430- P. string f (L. function_async ~async );
431- P. space f;
432- (match fn_state with
433- | Is_return | No_name _ -> ()
434- | Name_non_top x | Name_top x ->
435- ignore (Ext_pp_scope. ident inner_cxt f x));
436- param_body () );
437- pp_paren_params inner_cxt f lexical;
438- P. string f L. rparen;
439- match fn_state with
440- | Is_return | No_name _ -> () (* expression *)
441- | _ -> semi f
442- (* has binding, a statement *)
443404 in
444- handle
445- (match fn_state with
446- | (Name_top name | Name_non_top name) when Set_ident. mem lexical name
447- ->
448- (* TODO: when calculating lexical we should not include itself *)
449- Set_ident. remove lexical name
450- | _ -> lexical)
405+ handle ()
451406 in
452- enclose lexical ;
407+ enclose () ;
453408 outer_cxt
454409
455410(* Assume the cond would not change the context,
@@ -1048,7 +1003,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
10481003 P. string f L. else_;
10491004 P. space f;
10501005 brace_block cxt f s2)
1051- | While (label , e , s , _env ) ->
1006+ | While (label , e , s ) ->
10521007 (* FIXME: print scope as well *)
10531008 (match label with
10541009 | Some i ->
@@ -1076,7 +1031,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
10761031 let cxt = brace_block cxt f s in
10771032 semi f;
10781033 cxt
1079- | ForRange (for_ident_expression , finish , id , direction , s , env ) ->
1034+ | ForRange (for_ident_expression , finish , id , direction , s ) ->
10801035 let action cxt =
10811036 P. vgroup f 0 (fun _ ->
10821037 let cxt =
@@ -1147,24 +1102,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
11471102 in
11481103 brace_block cxt f s)
11491104 in
1150- let lexical = Js_closure. get_lexical_scope env in
1151- if Set_ident. is_empty lexical then action cxt
1152- else
1153- (* unlike function,
1154- [print for loop] has side effect,
1155- we should take it out
1156- *)
1157- let inner_cxt = Ext_pp_scope. merge cxt lexical in
1158- let lexical = Set_ident. elements lexical in
1159- P. vgroup f 0 (fun _ ->
1160- P. string f L. lparen;
1161- P. string f L. function_;
1162- pp_paren_params inner_cxt f lexical;
1163- let cxt = P. brace_vgroup f 0 (fun _ -> action inner_cxt) in
1164- pp_paren_params inner_cxt f lexical;
1165- P. string f L. rparen;
1166- semi f;
1167- cxt)
1105+ action cxt
11681106 | Continue s ->
11691107 continue f s;
11701108 cxt
0 commit comments