Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 2598a47

Browse files
Maximcristianoc
Maxim
authored andcommitted
Make processFunctionAttributes return a record instead of tuple
1 parent 54c56b4 commit 2598a47

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/res_parsetree_viewer.ml

+7-1
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,16 @@ let processUncurriedAttribute attrs =
5555
in
5656
process false [] attrs
5757

58+
type functionAttributesInfo = {
59+
async: bool;
60+
uncurried: bool;
61+
attributes: Parsetree.attributes;
62+
}
63+
5864
let processFunctionAttributes attrs =
5965
let rec process async uncurried acc attrs =
6066
match attrs with
61-
| [] -> (async, uncurried, List.rev acc)
67+
| [] -> {async; uncurried; attributes = List.rev acc}
6268
| ({Location.txt = "bs"}, _) :: rest -> process async true acc rest
6369
| ({Location.txt = "async"}, _) :: rest -> process true uncurried acc rest
6470
| attr :: rest -> process async uncurried (attr :: acc) rest

src/res_parsetree_viewer.mli

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ val functorType :
1717
val processUncurriedAttribute :
1818
Parsetree.attributes -> bool * Parsetree.attributes
1919

20+
type functionAttributesInfo = {
21+
async: bool;
22+
uncurried: bool;
23+
attributes: Parsetree.attributes;
24+
}
25+
2026
(* determines whether a function is async and/or uncurried based on the given attributes *)
21-
val processFunctionAttributes :
22-
Parsetree.attributes ->
23-
bool (* async *) * bool (* uncurried *) * Parsetree.attributes
27+
val processFunctionAttributes : Parsetree.attributes -> functionAttributesInfo
2428

2529
val hasAwaitAttribute : Parsetree.attributes -> bool
2630

src/res_printer.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3135,7 +3135,7 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
31353135
cmtTbl
31363136
| Pexp_fun _ | Pexp_newtype _ ->
31373137
let attrsOnArrow, parameters, returnExpr = ParsetreeViewer.funExpr e in
3138-
let async, uncurried, attrs =
3138+
let ParsetreeViewer.{async; uncurried; attributes = attrs} =
31393139
ParsetreeViewer.processFunctionAttributes attrsOnArrow
31403140
in
31413141
let returnExpr, typConstraint =
@@ -3302,7 +3302,7 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
33023302

33033303
and printPexpFun ~customLayout ~inCallback e cmtTbl =
33043304
let attrsOnArrow, parameters, returnExpr = ParsetreeViewer.funExpr e in
3305-
let async, uncurried, attrs =
3305+
let ParsetreeViewer.{async; uncurried; attributes = attrs} =
33063306
ParsetreeViewer.processFunctionAttributes attrsOnArrow
33073307
in
33083308
let returnExpr, typConstraint =

0 commit comments

Comments
 (0)