@@ -166,14 +166,6 @@ let exp_need_paren (e : J.expression) =
166
166
false
167
167
| Await _ -> false
168
168
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
-
177
169
(* * Print as underscore for unused vars, may not be
178
170
needed in the future *)
179
171
(* 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
383
375
P. space f;
384
376
P. brace_vgroup f 1 (fun _ -> function_body ~return_unit cxt f b)
385
377
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
+ (
390
381
match fn_state with
391
382
| Is_return ->
392
383
return_sp f;
@@ -410,46 +401,10 @@ and pp_function ~return_unit ~async ~is_method cxt (f : P.t) ~fn_state
410
401
P. space f;
411
402
ignore (Ext_pp_scope. ident inner_cxt f x : cxt );
412
403
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 *)
443
404
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 ()
451
406
in
452
- enclose lexical ;
407
+ enclose () ;
453
408
outer_cxt
454
409
455
410
(* Assume the cond would not change the context,
@@ -1048,7 +1003,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
1048
1003
P. string f L. else_;
1049
1004
P. space f;
1050
1005
brace_block cxt f s2)
1051
- | While (label , e , s , _env ) ->
1006
+ | While (label , e , s ) ->
1052
1007
(* FIXME: print scope as well *)
1053
1008
(match label with
1054
1009
| Some i ->
@@ -1076,7 +1031,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
1076
1031
let cxt = brace_block cxt f s in
1077
1032
semi f;
1078
1033
cxt
1079
- | ForRange (for_ident_expression , finish , id , direction , s , env ) ->
1034
+ | ForRange (for_ident_expression , finish , id , direction , s ) ->
1080
1035
let action cxt =
1081
1036
P. vgroup f 0 (fun _ ->
1082
1037
let cxt =
@@ -1147,24 +1102,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
1147
1102
in
1148
1103
brace_block cxt f s)
1149
1104
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
1168
1106
| Continue s ->
1169
1107
continue f s;
1170
1108
cxt
0 commit comments