@@ -164,14 +164,6 @@ let exp_need_paren (e : J.expression) =
164164 | Await _ -> false
165165 | Tagged_template _ -> false
166166
167- let comma_idents (cxt : cxt ) f ls = iter_lst cxt f ls Ext_pp_scope. ident comma
168-
169- let pp_paren_params (inner_cxt : cxt ) (f : Ext_pp.t ) (lexical : Ident.t list ) :
170- unit =
171- P. string f L. lparen;
172- let (_ : cxt ) = comma_idents inner_cxt f lexical in
173- P. string f L. rparen
174-
175167(* * Print as underscore for unused vars, may not be
176168 needed in the future *)
177169(* let ipp_ident cxt f id (un_used : bool) =
@@ -381,10 +373,9 @@ and pp_function ~return_unit ~async ~is_method cxt (f : P.t) ~fn_state
381373 P. space f;
382374 P. brace_vgroup f 1 (fun _ -> function_body ~return_unit cxt f b)
383375 in
384- let lexical : Set_ident.t = Js_fun_env. get_lexical_scope env in
385- let enclose lexical =
386- let handle lexical =
387- if Set_ident. is_empty lexical then (
376+ let enclose () =
377+ let handle () =
378+ (
388379 match fn_state with
389380 | Is_return ->
390381 return_sp f;
@@ -408,46 +399,10 @@ and pp_function ~return_unit ~async ~is_method cxt (f : P.t) ~fn_state
408399 P. space f;
409400 ignore (Ext_pp_scope. ident inner_cxt f x : cxt );
410401 param_body () )
411- else
412- (* print our closure as
413- {[(function(x,y){ return function(..){...}} (x,y))]}
414- Maybe changed to `let` in the future
415- *)
416- let lexical = Set_ident. elements lexical in
417- (match fn_state with
418- | Is_return -> return_sp f
419- | No_name _ -> ()
420- | Name_non_top name | Name_top name ->
421- ignore (pp_var_assign inner_cxt f name : cxt ));
422- if async then P. string f L. await;
423- P. string f L. lparen;
424- P. string f (L. function_async ~async );
425- pp_paren_params inner_cxt f lexical;
426- P. brace_vgroup f 0 (fun _ ->
427- return_sp f;
428- P. string f (L. function_async ~async );
429- P. space f;
430- (match fn_state with
431- | Is_return | No_name _ -> ()
432- | Name_non_top x | Name_top x ->
433- ignore (Ext_pp_scope. ident inner_cxt f x));
434- param_body () );
435- pp_paren_params inner_cxt f lexical;
436- P. string f L. rparen;
437- match fn_state with
438- | Is_return | No_name _ -> () (* expression *)
439- | _ -> semi f
440- (* has binding, a statement *)
441402 in
442- handle
443- (match fn_state with
444- | (Name_top name | Name_non_top name) when Set_ident. mem lexical name
445- ->
446- (* TODO: when calculating lexical we should not include itself *)
447- Set_ident. remove lexical name
448- | _ -> lexical)
403+ handle ()
449404 in
450- enclose lexical ;
405+ enclose () ;
451406 outer_cxt
452407
453408(* Assume the cond would not change the context,
@@ -1065,7 +1020,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
10651020 P. string f L. else_;
10661021 P. space f;
10671022 brace_block cxt f s2)
1068- | While (label , e , s , _env ) ->
1023+ | While (label , e , s ) ->
10691024 (* FIXME: print scope as well *)
10701025 (match label with
10711026 | Some i ->
@@ -1093,7 +1048,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
10931048 let cxt = brace_block cxt f s in
10941049 semi f;
10951050 cxt
1096- | ForRange (for_ident_expression , finish , id , direction , s , env ) ->
1051+ | ForRange (for_ident_expression , finish , id , direction , s ) ->
10971052 let action cxt =
10981053 P. vgroup f 0 (fun _ ->
10991054 let cxt =
@@ -1164,24 +1119,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
11641119 in
11651120 brace_block cxt f s)
11661121 in
1167- let lexical = Js_closure. get_lexical_scope env in
1168- if Set_ident. is_empty lexical then action cxt
1169- else
1170- (* unlike function,
1171- [print for loop] has side effect,
1172- we should take it out
1173- *)
1174- let inner_cxt = Ext_pp_scope. merge cxt lexical in
1175- let lexical = Set_ident. elements lexical in
1176- P. vgroup f 0 (fun _ ->
1177- P. string f L. lparen;
1178- P. string f L. function_;
1179- pp_paren_params inner_cxt f lexical;
1180- let cxt = P. brace_vgroup f 0 (fun _ -> action inner_cxt) in
1181- pp_paren_params inner_cxt f lexical;
1182- P. string f L. rparen;
1183- semi f;
1184- cxt)
1122+ action cxt
11851123 | Continue s ->
11861124 continue f s;
11871125 cxt
0 commit comments