Skip to content

Commit 394ca93

Browse files
committed
Move isTupleArray to res_parsetree_viewer
1 parent 71fc50c commit 394ca93

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
@@ -747,3 +747,13 @@ let isRewrittenUnderscoreApplySugar expr =
747747
match expr.pexp_desc with
748748
| Pexp_ident {txt = Longident.Lident "_"} -> true
749749
| _ -> false
750+
751+
let isTupleArray (expr : Parsetree.expression) =
752+
let isPlainTuple (expr : Parsetree.expression) =
753+
match expr with
754+
| {pexp_desc = Pexp_tuple _} -> true
755+
| _ -> false
756+
in
757+
match expr with
758+
| {pexp_desc = Pexp_array items} -> List.for_all isPlainTuple items
759+
| _ -> false

jscomp/syntax/src/res_parsetree_viewer.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,5 @@ val hasIfLetAttribute : Parsetree.attributes -> bool
170170
val isRewrittenUnderscoreApplySugar : Parsetree.expression -> bool
171171

172172
val isFunNewtype : Parsetree.expression -> bool
173+
174+
val isTupleArray : Parsetree.expression -> bool

jscomp/syntax/src/res_printer.ml

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

430-
let isTupleArray (expr : Parsetree.expression) =
431-
let isPlainTuple (expr : Parsetree.expression) =
432-
match expr with
433-
| {pexp_desc = Pexp_tuple _} -> true
434-
| _ -> false
435-
in
436-
match expr with
437-
| {pexp_desc = Pexp_array items} -> List.for_all isPlainTuple items
438-
| _ -> false
439-
440430
(* Exotic identifiers in poly-vars have a "lighter" syntax: #"ease-in" *)
441431
let printPolyVarIdent txt =
442432
(* numeric poly-vars don't need quotes: #644 *)
@@ -4016,7 +4006,7 @@ and printPexpApply ~state expr cmtTbl =
40164006
};
40174007
},
40184008
[(Nolabel, keyValues)] )
4019-
when isTupleArray keyValues ->
4009+
when Res_parsetree_viewer.isTupleArray keyValues ->
40204010
Doc.concat
40214011
[
40224012
Doc.text "dict{";

0 commit comments

Comments
 (0)