Skip to content

Commit 861fbcf

Browse files
bloodyowlcknitt
authored andcommitted
Move isTupleArray to res_parsetree_viewer
1 parent 6bad5b1 commit 861fbcf

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

jscomp/syntax/src/res_parsetree_viewer.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,3 +743,13 @@ let is_rewritten_underscore_apply_sugar expr =
743743
match expr.pexp_desc with
744744
| Pexp_ident {txt = Longident.Lident "_"} -> true
745745
| _ -> false
746+
747+
let is_tuple_array (expr : Parsetree.expression) =
748+
let is_plain_tuple (expr : Parsetree.expression) =
749+
match expr with
750+
| {pexp_desc = Pexp_tuple _} -> true
751+
| _ -> false
752+
in
753+
match expr with
754+
| {pexp_desc = Pexp_array items} -> List.for_all is_plain_tuple items
755+
| _ -> false

jscomp/syntax/src/res_parsetree_viewer.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,5 @@ val has_if_let_attribute : Parsetree.attributes -> bool
164164
val is_rewritten_underscore_apply_sugar : Parsetree.expression -> bool
165165

166166
val is_fun_newtype : Parsetree.expression -> bool
167+
168+
val is_tuple_array : Parsetree.expression -> bool

jscomp/syntax/src/res_printer.ml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -429,16 +429,6 @@ let is_valid_numeric_polyvar_number (x : string) =
429429
| _ -> false)
430430
else a >= 48
431431

432-
let is_tuple_array (expr : Parsetree.expression) =
433-
let is_plain_tuple (expr : Parsetree.expression) =
434-
match expr with
435-
| {pexp_desc = Pexp_tuple _} -> true
436-
| _ -> false
437-
in
438-
match expr with
439-
| {pexp_desc = Pexp_array items} -> List.for_all is_plain_tuple items
440-
| _ -> false
441-
442432
(* Exotic identifiers in poly-vars have a "lighter" syntax: #"ease-in" *)
443433
let print_poly_var_ident txt =
444434
(* numeric poly-vars don't need quotes: #644 *)
@@ -4091,7 +4081,7 @@ and print_pexp_apply ~state expr cmt_tbl =
40914081
};
40924082
},
40934083
[(Nolabel, key_values)] )
4094-
when is_tuple_array key_values ->
4084+
when Res_parsetree_viewer.is_tuple_array key_values ->
40954085
Doc.concat
40964086
[
40974087
Doc.text "dict{";

0 commit comments

Comments
 (0)