Skip to content

Commit 3fbe2b8

Browse files
committedMay 9, 2020
1 parent 0aefbeb commit 3fbe2b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+5666
-5580
lines changed
 

‎jscomp/core/js_dump.ml

+26-12
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ type fn_exp_state =
367367
| Is_return (* for sure no name *)
368368
| Name_top of Ident.t
369369
| Name_non_top of Ident.t
370-
| No_name
370+
| No_name of {single_arg : bool} (* true means for sure, false -- not sure *)
371+
372+
let default_fn_exp_state = No_name {single_arg = false}
371373

372374
(* TODO: refactoring
373375
Note that {!pp_function} could print both statement and expression when [No_name] is given
@@ -410,7 +412,7 @@ and pp_function ~is_method
410412
semi f ;
411413
cxt
412414
| Is_return
413-
| No_name ->
415+
| No_name _ ->
414416
if fn_state = Is_return then
415417
return_sp f ;
416418
optimize len ~p:(arity = NA && len <=8) cxt f v)
@@ -419,7 +421,7 @@ and pp_function ~is_method
419421
let set_env : Set_ident.t = (** identifiers will be printed following*)
420422
match fn_state with
421423
| Is_return
422-
| No_name ->
424+
| No_name _ ->
423425
Js_fun_env.get_unbounded env
424426
| Name_top id | Name_non_top id ->
425427
Set_ident.add (Js_fun_env.get_unbounded env ) id in
@@ -461,15 +463,19 @@ and pp_function ~is_method
461463
then
462464
(
463465
match fn_state with
464-
| Is_return
465-
| No_name ->
466-
if fn_state = Is_return then
467-
return_sp f ;
466+
| Is_return ->
467+
return_sp f ;
468468
(* see # 1692, add a paren for annoymous function for safety *)
469469
P.paren_group f 1 (fun _ ->
470470
P.string f L.function_;
471471
P.space f ;
472472
param_body ())
473+
| No_name {single_arg } ->
474+
(* see # 1692, add a paren for annoymous function for safety *)
475+
P.cond_paren_group f (not single_arg) 1 (fun _ ->
476+
P.string f L.function_;
477+
P.space f ;
478+
param_body ())
473479
| Name_non_top x ->
474480
ignore (pp_var_assign inner_cxt f x : cxt );
475481
P.string f L.function_;
@@ -490,7 +496,7 @@ and pp_function ~is_method
490496
(
491497
match fn_state with
492498
| Is_return -> return_sp f
493-
| No_name -> ()
499+
| No_name _ -> ()
494500
| Name_non_top name | Name_top name->
495501
ignore (pp_var_assign inner_cxt f name : cxt)
496502
)
@@ -504,14 +510,14 @@ and pp_function ~is_method
504510
P.space f ;
505511
(match fn_state with
506512
| Is_return
507-
| No_name -> ()
513+
| No_name _ -> ()
508514
| Name_non_top x | Name_top x -> ignore (Ext_pp_scope.ident inner_cxt f x));
509515
param_body ());
510516
pp_paren_params inner_cxt f lexical;
511517
P.string f L.rparen;
512518
match fn_state with
513519
| Is_return
514-
| No_name -> () (* expression *)
520+
| No_name _ -> () (* expression *)
515521
| _ -> semi f (* has binding, a statement *) in
516522
handle
517523
(match fn_state with
@@ -598,7 +604,7 @@ and expression_desc cxt ~(level:int) f x : cxt =
598604
comma_sp f;
599605
expression ~level:0 cxt f e2 )
600606
| Fun (is_method, l, b, env) -> (* TODO: dump for comments *)
601-
pp_function ~is_method cxt f ~fn_state:No_name l b env
607+
pp_function ~is_method cxt f ~fn_state:default_fn_exp_state l b env
602608
(* TODO:
603609
when [e] is [Js_raw_code] with arity
604610
print it in a more precise way
@@ -616,7 +622,15 @@ and expression_desc cxt ~(level:int) f x : cxt =
616622
| {arity = Full }, _
617623
| _, [] ->
618624
let cxt = expression ~level:15 cxt f e in
619-
P.paren_group f 1 (fun _ -> arguments cxt f el )
625+
P.paren_group f 1 (fun _ ->
626+
match el with
627+
| [{expression_desc = Fun (is_method, l,b,env)}]
628+
->
629+
pp_function ~is_method cxt f ~fn_state:(No_name {single_arg = true})
630+
l b env
631+
| _ ->
632+
arguments cxt f el
633+
)
620634

621635
| _ , _ ->
622636
let len = List.length el in

‎jscomp/main/builtin_cmj_datasets.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(* 3382017b6947d0a2e792f407b8a3ac0c *)
1+
(* fead54da4fde007417b8ccf419babc41 *)
22
let module_names : string array = Obj.magic (
33
"Gc" (* 220 *),
44
"Js" (* 23 *),
@@ -11,7 +11,7 @@ let module_names : string array = Obj.magic (
1111
"Sys" (* 159 *),
1212
"Belt" (* 23 *),
1313
"Char" (* 243 *),
14-
"Lazy" (* 285 *),
14+
"Lazy" (* 288 *),
1515
"List" (* 922 *),
1616
"Node" (* 36 *),
1717
"Sort" (* 64 *),
@@ -114,7 +114,7 @@ let module_names : string array = Obj.magic (
114114
"Belt_MutableSet" (* 2115 *),
115115
"CamlinternalMod" (* 23 *),
116116
"Js_typed_array2" (* 23 *),
117-
"CamlinternalLazy" (* 195 *),
117+
"CamlinternalLazy" (* 104 *),
118118
"Belt_MutableQueue" (* 574 *),
119119
"Belt_MutableStack" (* 530 *),
120120
"Belt_SortArrayInt" (* 184 *),
@@ -152,7 +152,7 @@ let module_data : string array = Obj.magic (
152152
(* Sys *)"\132\149\166\190\000\000\000\139\000\000\000 \000\000\000n\000\000\000d\160\224\176&cygwin\144@\144\146C\176*getenv_opt\144\160\160A@@@\176*set_signal\144\160\160B@@@\176+catch_break\144\160\160A@@@\1767enable_runtime_warnings\144\160\160A@@@\1768runtime_warnings_enabled\144\160\160A@@@A",
153153
(* Belt *)"\132\149\166\190\000\000\000\003\000\000\000\001\000\000\000\003\000\000\000\003\160\128A",
154154
(* Char *)"\132\149\166\190\000\000\000\223\000\000\000<\000\000\000\197\000\000\000\186\160\b\000\000 \000\176#chr\144\160\160A@@@\176%equal\144\160\160B@@@\176'compare\144\160\160B@@\144\180B\160\176\001\004\001\"c1@\160\176\001\004\002\"c2@@\151\176I\160\144\004\t\160\144\004\b@\176\1922stdlib-406/char.ml\000K\001\n\001\001\n\021\192\004\002\000K\001\n\001\001\n&@\176'escaped\144\160\160A@@@\176)lowercase\144\160\160A@@@\176)uppercase\144\160\160A@@@\176/lowercase_ascii\144\160\160A@@@\176/uppercase_ascii\144\160\160A@@@A",
155-
(* Lazy *)"\132\149\166\190\000\000\001\t\000\000\000=\000\000\000\213\000\000\000\197\160\240\176&is_val\144\160\160A@@@\176(from_fun\144\160\160A@@\144\180A\160\176\001\003\239!f@@\151\176\176@\146\160#tag%valueA\160\146\160\001\000\246@\160\180@@\147\192\144\004\017\160\146A@\176\1922stdlib-406/lazy.ml|\001\t\175\001\t\235\192\004\002|\001\t\175\001\t\239@@@\176\192>stdlib-406/camlinternalLazy.mln\001\b+\001\b8\192\004\002n\001\b+\001\b[@\176(from_val\144\160\160A@@@\176)force_val\144\160\160A@@@\176+lazy_is_val\144\0042@\176-lazy_from_fun\144\0040@\176-lazy_from_val\144\004\016@A",
155+
(* Lazy *)"\132\149\166\190\000\000\001\012\000\000\000@\000\000\000\225\000\000\000\210\160\240\176&is_val\144\160\160A@@@\176(from_fun\144\160\160A@@\144\180A\160\176\001\003\239!f@@\147\192\151\176\161C\146(from_fun\160\145\176@0CamlinternalLazyA@\176\192&_none_A@\000\255\004\002A\160\180@@\147\192\144\004\021\160\146A@\176\1922stdlib-406/lazy.ml|\001\t\175\001\t\235\192\004\002|\001\t\175\001\t\239@@@\176\192\004\004|\001\t\175\001\t\192\192\004\005|\001\t\175\001\t\240@A\176(from_val\144\160\160A@@@\176)force_val\144\160\160A@@@\176+lazy_is_val\144\0045@\176-lazy_from_fun\144\0043@\176-lazy_from_val\144\004\016@A",
156156
(* List *)"\132\149\166\190\000\000\003\134\000\000\001\020\000\000\003\135\000\000\003T\160\b\000\000\208\000\176\"hd\144\160\160A@@@\176\"tl\144\160\160A@@@\176#map\144\160\160B@@@\176#mem\144\160\160B@@@\176#nth\144\160\160B@@@\176#rev\144\160\160A@@@\176$assq\144\160\160B@@@\176$cons\144\160\160B@@\144\180B\160\176\001\003\241!a@\160\176\001\003\242!l@@\151\176\176@\160\"::A@\160\144\004\012\160\144\004\011@\176\1922stdlib-406/list.mlX\001\004\193\001\004\208\192\004\002X\001\004\193\001\004\212@\176$find\144\160\160B@@@\176$init\144\160\160B@@@\176$iter\144\160\160B@@@\176$map2\144\160\160C@@@\176$mapi\144\160\160B@@@\176$memq\144\160\160B@@@\176$sort\144\160\160B@@@\176%assoc\144\160\160B@@@\176%iter2\144\160\160C@@@\176%iteri\144\160\160B@@@\176%merge\144\160\160C@@@\176%split\144\160\160A@@@\176&append\144\160\160B@@@\176&concat\144\160\160A@@@\176&exists\144\160\160B@@@\176&filter\144\160\160A\160A@@@\176&length\144\160\160A@@@\176'combine\144\160\160B@@@\176'exists2\144\160\160C@@@\176'flatten\144\004\031@\176'for_all\144\160\160B@@@\176'nth_opt\144\160\160B@@@\176'rev_map\144\160\160B@@@\176(assq_opt\144\160\160B@@@\176(find_all\144\004,@\176(find_opt\144\160\160B@@@\176(for_all2\144\160\160C@@@\176(mem_assq\144\160\160B@@@\176(rev_map2\144\160\160C@@@\176)assoc_opt\144\160\160B@@@\176)fast_sort\144\004u@\176)fold_left\144\160\160C@@@\176)mem_assoc\144\160\160B@@@\176)partition\144\160\160B@@@\176)sort_uniq\144\160\160B@@@\176*fold_left2\144\160\160D@@@\176*fold_right\144\160\160C@@@\176*rev_append\144\160\160B@@@\176+fold_right2\144\160\160D@@@\176+remove_assq\144\160\160B@@@\176+stable_sort\144\004\165@\176,remove_assoc\144\160\160B@@@\176/compare_lengths\144\160\160B@@@\1763compare_length_with\144\160\160B@@@A",
157157
(* Node *)"\132\149\166\190\000\000\000\016\000\000\000\007\000\000\000\020\000\000\000\019\160\144\176$test\144\160\160A@@@A",
158158
(* Sort *)"\132\149\166\190\000\000\000,\000\000\000\017\000\000\0004\000\000\0001\160\176\176$list\144\160\160B@@@\176%array\144\160\160B@@@\176%merge\144\160\160C@@@A",
@@ -255,7 +255,7 @@ let module_data : string array = Obj.magic (
255255
(* Belt_MutableSet *)"\132\149\166\190\000\000\b/\000\000\002J\000\000\007{\000\000\0076\160\b\000\000\168\000\176\"eq\144\160\160B@@@\176#add\144\160\160B@@@\176#cmp\144\160\160B@@@\176#get\144\160\160B@@@\176#has\144\160\160B@@@\176$copy\144\160\160A@@@\176$diff\144\160\160B@@@\176$keep\144\160\160B@@@\176$make\144\160\160A@@\144\180A\160\176\001\005\154\"id@@\151\176\176@\146\160#cmp$dataA\160\151\176\161@\146#cmp\160\144\004\017@\176\192&_none_A@\000\255\004\002A\160\146A@\176\1929others/belt_MutableSet.ml\001\000\192\001\020\235\001\020\237\192\004\002\001\000\192\001\020\235\001\021\b@\176$size\144\160\160A@@\144\180A\160\176\001\005\198!d@@\147\192\151\176\161^\146$size\160\145\176@3Belt_internalAVLsetA@\004\030\160\151\176\161A\161\004,A\160\144\004\020@\176\192\004 \001\000\215\001\023j\001\023s\192\004!\001\000\215\001\023j\001\023{@@\176\192\004#\001\000\215\001\023j\001\023l\004\003@A\176$some\144\160\160B@@@\176%every\144\160\160B@@@\176%keepU\144\160\160B@@@\176%someU\144\160\160B@@\144\180B\160\176\001\005\191!d@\160\176\001\005\192!p@@\147\192\151\176\161Q\146%someU\160\145\0043@\004O\160\151\176\161A\161\004]A\160\144\004\021@\176\192\004Q\001\000\212\001\023\n\001\023\"\192\004R\001\000\212\001\023\n\001\023*@\160\144\004\023@\176\192\004V\001\000\212\001\023\n\001\023\026\192\004W\001\000\212\001\023\n\001\023,@A\176%split\144\160\160B@@@\176%union\144\160\160B@@@\176&everyU\144\160\160B@@\144\180B\160\176\001\005\184!d@\160\176\001\005\185!p@@\147\192\151\176\161O\146&everyU\160\145\004b@\004~\160\151\176\161A\161\004\140A\160\144\004\021@\176\192\004\128\001\000\210\001\022\180\001\022\206\192\004\129\001\000\210\001\022\180\001\022\214@\160\144\004\023@\176\192\004\133\001\000\210\001\022\180\001\022\197\192\004\134\001\000\210\001\022\180\001\022\216@A\176&getExn\144\160\160B@@@\176&reduce\144\160\160C@@@\176&remove\144\160\160B@@@\176&subset\144\160\160B@@@\176&toList\144\160\160A@@\144\180A\160\176\001\005\200!d@@\147\192\151\176\161_\146&toList\160\145\004\152@\004\180\160\151\176\161A\161\004\194A\160\144\004\018@\176\192\004\182\001\000\217\001\023\139\001\023\150\192\004\183\001\000\217\001\023\139\001\023\158@@\176\192\004\185\001\000\217\001\023\139\001\023\141\004\003@A\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@@\176'maximum\144\160\160A@@\144\180A\160\176\001\005\163!d@@\147\192\151\176\161F\146'maximum\160\145\004\193@\004\221\160\151\176\161A\161\004\235A\160\144\004\018@\176\192\004\223\001\000\202\001\021\163\001\021\175\192\004\224\001\000\202\001\021\163\001\021\183@@\176\192\004\226\001\000\202\001\021\163\001\021\165\004\003@A\176'minimum\144\160\160A@@\144\180A\160\176\001\005\159!d@@\147\192\151\176\161D\146'minimum\160\145\004\224@\004\252\160\151\176\161A\161\005\001\nA\160\144\004\018@\176\192\004\254\001\000\198\001\021J\001\021V\192\004\255\001\000\198\001\021J\001\021^@@\176\192\005\001\001\001\000\198\001\021J\001\021L\004\003@A\176'reduceU\144\160\160C@@@\176'toArray\144\160\160A@@\144\180A\160\176\001\005\202!d@@\147\192\151\176\161b\146'toArray\160\145\005\001\004@\005\001 \160\151\176\161A\161\005\001.A\160\144\004\018@\176\192\005\001\"\001\000\219\001\023\176\001\023\188\192\005\001#\001\000\219\001\023\176\001\023\196@@\176\192\005\001%\001\000\219\001\023\176\001\023\178\004\003@A\176(addCheck\144\160\160B@@@\176(forEachU\144\160\160B@@\144\180B\160\176\001\005\167!d@\160\176\001\005\168!f@@\147\192\151\176\161K\146(forEachU\160\145\005\001+@\005\001G\160\151\176\161A\161\005\001UA\160\144\004\021@\176\192\005\001I\001\000\206\001\021\232\001\022\006\192\005\001J\001\000\206\001\021\232\001\022\014@\160\144\004\023@\176\192\005\001N\001\000\206\001\021\232\001\021\251\192\005\001O\001\000\206\001\021\232\001\022\016@A\176)fromArray\144\160\160B@@@\176)intersect\144\160\160B@@@\176)mergeMany\144\160\160B@@@\176)partition\144\160\160B@@@\176*partitionU\144\160\160B@@@\176*removeMany\144\160\160B@@@\176+removeCheck\144\160\160B@@@\176,getUndefined\144\160\160B@@@\176,maxUndefined\144\160\160A@@\144\180A\160\176\001\005\165!d@@\147\192\151\176\161G\146,maxUndefined\160\145\005\001u@\005\001\145\160\151\176\161A\161\005\001\159A\160\144\004\018@\176\192\005\001\147\001\000\204\001\021\205\001\021\222\192\005\001\148\001\000\204\001\021\205\001\021\230@@\176\192\005\001\150\001\000\204\001\021\205\001\021\207\004\003@A\176,minUndefined\144\160\160A@@\144\180A\160\176\001\005\161!d@@\147\192\151\176\161E\146,minUndefined\160\145\005\001\148@\005\001\176\160\151\176\161A\161\005\001\190A\160\144\004\018@\176\192\005\001\178\001\000\200\001\021x\001\021\137\192\005\001\179\001\000\200\001\021x\001\021\145@@\176\192\005\001\181\001\000\200\001\021x\001\021z\004\003@A\1765fromSortedArrayUnsafe\144\160\160B@@\144\180B\160\176\001\005\206\"xs@\160\176\001\005\207\"id@@\151\176\176@\146\160\005\001\216\005\001\215A\160\151\176\161@\146#cmp\160\144\004\015@\005\001\214\160\147\192\151\176\161e\1465fromSortedArrayUnsafe\160\145\005\001\196@\005\001\224\160\144\004\030@\176\192\005\001\221\001\000\223\001\024B\001\024L\192\005\001\222\001\000\223\001\024B\001\024h@A@\176\192\005\001\224\001\000\223\001\024B\001\024D\192\005\001\225\001\000\223\001\024B\001\024v@\1766checkInvariantInternal\144\160\160A@@\144\180A\160\176\001\005\210!d@@\147\192\151\176\161`\1466checkInvariantInternal\160\145\005\001\223@\005\001\251\160\151\176\161A\161\005\002\tA\160\144\004\018@\176\192\005\001\253\001\000\226\001\024\152\001\024\179\192\005\001\254\001\000\226\001\024\152\001\024\187@@\176\192\005\002\000\001\000\226\001\024\152\001\024\154\004\003@AA",
256256
(* CamlinternalMod *)"\132\149\166\190\000\000\000\003\000\000\000\001\000\000\000\003\000\000\000\003\160\128A",
257257
(* Js_typed_array2 *)"\132\149\166\190\000\000\000\003\000\000\000\001\000\000\000\003\000\000\000\003\160\128A",
258-
(* CamlinternalLazy *)"\132\149\166\190\000\000\000\175\000\000\0000\000\000\000\158\000\000\000\148\160\208\176%force\144\160\160A@@@\176&is_val\144\160\160A@@@\176(from_fun\144\160\160A@@\144\180A\160\176\001\004i!f@@\151\176\176@\146\160#tag%valueA\160\146\160\001\000\246@\160\144\004\014@\176\192>stdlib-406/camlinternalLazy.mln\001\b+\001\b8\192\004\002n\001\b+\001\b[@\176(from_val\144\160\160A@@@\176)force_val\144\160\160A@@@A",
258+
(* CamlinternalLazy *)"\132\149\166\190\000\000\000T\000\000\000\027\000\000\000W\000\000\000R\160\208\176%force\144\160\160A@@@\176&is_val\144\160\160A@@@\176(from_fun\144\160\160A@@@\176(from_val\144\160\160A@@@\176)force_val\144\160\160A@@@A",
259259
(* Belt_MutableQueue *)"\132\149\166\190\000\000\002*\000\000\000\168\000\000\002!\000\000\002\006\160\b\000\000T\000\176#add\144\160\160B@@@\176#map\144\160\160B@@@\176#pop\144\160\160A@@@\176$copy\144\160\160A@@@\176$make\144\160\160A@@\144\180A\160\176\001\003\245%param@@\151\176\176@\146\176&length%first$lastA\160\146\160@@\160\146A\160\146A@\176\192;others/belt_MutableQueue.mlb\001\005\176\001\005\180\192\004\002e\001\005\220\001\005\239@\176$mapU\144\160\160B@@@\176$peek\144\160\160A@@@\176$size\144\160\160A@@\144\180A\160\176\001\004\180!q@@\151\176\161@\161\004&A\160\144\004\b@\176\192\004\030\001\000\163\001\016Y\001\016[\192\004\031\001\000\163\001\016Y\001\016c@\176%clear\144\160\160A@@@\176&popExn\144\160\160A@@@\176&reduce\144\160\160C@@@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@\144\180A\160\176\001\004\178!q@@\151\176\151@\160\151\176\161@\161\004QA\160\144\004\012@\176\192\004I\001\000\160\001\016<\001\016>\192\004J\001\000\160\001\016<\001\016F@\160\146\160@@@\176\004\006\192\004O\001\000\160\001\016<\001\016J@\176'peekExn\144\160\160A@@@\176'reduceU\144\160\160C@@@\176'toArray\144\160\160A@@@\176(forEachU\144\160\160B@@@\176(transfer\144\160\160B@@@\176)fromArray\144\160\160A@@@\176,popUndefined\144\160\160A@@@\176-peekUndefined\144\160\160A@@@A",
260260
(* Belt_MutableStack *)"\132\149\166\190\000\000\001\254\000\000\000\150\000\000\001\237\000\000\001\216\160\b\000\0008\000\176#pop\144\160\160A@@@\176#top\144\160\160A@@@\176$copy\144\160\160A@@\144\180A\160\176\001\003\246!s@@\151\176\176@\146\144$rootA\160\151\176\161@\161\004\006A\160\144\004\015@\176\192;others/belt_MutableStack.mlf\001\005\219\001\005\254\192\004\002f\001\005\219\001\006\004@@\176\192\004\004f\001\005\219\001\005\246\192\004\005f\001\005\219\001\006\005@\176$make\144\160\160A@@\144\180A\160\176\001\003\242%param@@\151\176\176@\146\144\004\030A\160\146A@\176\192\004\024b\001\005\159\001\005\173\192\004\025b\001\005\159\001\005\186@\176$push\144\160\160B@@@\176$size\144\160\160A@@@\176%clear\144\160\160A@@\144\180A\160\176\001\003\244!s@@\151\176\162@\144\004;\160\144\004\b\160\146A@\176\192\0047d\001\005\188\001\005\203\192\0048d\001\005\188\001\005\217@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@\144\180A\160\176\001\004`!s@@\151\176\151@\160\151\176\161@\161\004YA\160\144\004\012@\176\192\004Su\001\007\014\001\007\030\192\004Tu\001\007\014\001\007$@\160\146A@\176\004\005\192\004Xu\001\007\014\001\007+@\176(forEachU\144\160\160B@@@\176,popUndefined\144\160\160A@@@\176,topUndefined\144\160\160A@@@\176.dynamicPopIter\144\160\160B@@@\176/dynamicPopIterU\144\160\160B@@@A",
261261
(* Belt_SortArrayInt *)"\132\149\166\190\000\000\000\164\000\000\000*\000\000\000\144\000\000\000\132\160\b\000\000 \000\176$diff\144\160\160H@@@\176%union\144\160\160H@@@\176(isSorted\144\160\160A@@@\176)intersect\144\160\160H@@@\176*stableSort\144\160\160A@@@\176,binarySearch\144\160\160B@@@\1761stableSortInPlace\144\160\160A@@@\1764strictlySortedLength\144\160\160A@@@A",

0 commit comments

Comments
 (0)