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

Done, but do not merge yet: Async/Await syntax. #600

Merged
merged 22 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
21c01e6
Implement parsing of `await` expressions.
Jul 4, 2022
5995738
Implement parsing of `async` expressions
Jul 4, 2022
454d5b6
Make "await". and "async" non-keywords.
Jul 4, 2022
686fa53
Implement printer support for async arrow expressions
Jul 4, 2022
5c91bc4
Implement printer support for await expressions
Jul 4, 2022
03db389
Implement printing of parens (precedence) for await expressions
Jul 4, 2022
9e711a4
Make sure the "async" identifier can be used without being interprete…
Jul 4, 2022
d0b7cb1
Make `await` a keyword again.
Jul 6, 2022
0283e8d
Remove `assert false` branch from async arrow expression parsing
Jul 6, 2022
dc85c21
Make `processFunctionAttributes` return a record instead of tuple
Jul 6, 2022
66defd5
Refactor code style "async" token lookahead
Jul 7, 2022
ff69dfa
Rename @await/@async to @res.await/@res.async
Jul 7, 2022
3d5af74
Alphabetically sort variant cases in `isBlockExprStart`
Jul 7, 2022
702d586
Sort variant cases `isExprStart` alphabetically
Jul 7, 2022
046d1e3
Extract printing of "async " in a helper
Jul 7, 2022
41844e6
Document ternary colon vs async arrow expression colon
Jul 7, 2022
fcd3c32
Add extra test case for async arrow expressions in ternary true branches
Jul 7, 2022
d20b149
Sort attribute variant cases on `hasAttributes` and `filterParsingAttrs`
Jul 7, 2022
3b17a08
Document Lident "async" branch in `parseBracedOrRecordExpr`.
Jul 7, 2022
bff364e
Fix printing of await expression inside binary expressions
Jul 7, 2022
c15dee0
Implement printing of parens for rhs of await expression correctly.
Jul 7, 2022
5e9b914
Update CHANGELOG.md
cristianoc Jul 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 32 additions & 27 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
## Unreleased
## Master

* Fix printing for inline nullary functor types [#477](https://github.com/rescript-lang/syntax/pull/477)
* Fix stripping of quotes for empty poly variants [#474](https://github.com/rescript-lang/syntax/pull/474)
* Implement syntax for arity zero vs arity one in uncurried application in [#139](https://github.com/rescript-lang/syntax/pull/139)
* Fix parsing of first class module exprs as part of binary/ternary expr in [#256](https://github.com/rescript-lang/syntax/pull/256)
* Fix formatter hanging on deeply nested function calls [#261](https://github.com/rescript-lang/syntax/issues/261)
* Remove parsing of "import" and "export" which was never officially supported.
#### :rocket: New Feature

## ReScript 9.0.0
- Add surface syntax for `async`/`await` https://github.com/rescript-lang/syntax/pull/600

## ReScript 10.0

* Fix parsing of poly-var typexpr consisting of one tag-spec-first in [#254](https://github.com/rescript-lang/syntax/pull/254)
* Implement new syntax for guards on pattern match cases in [#248](https://github.com/rescript-lang/syntax/pull/248)
* Implement intelligent breaking for poly-var type expressions in [#246](https://github.com/rescript-lang/syntax/pull/246)
* Improve indentation of fast pipe chain in let binding in [#244](https://github.com/rescript-lang/syntax/pull/244)
* Improve printing of non-callback arguments in call expressions with callback in [#241](https://github.com/rescript-lang/syntax/pull/241/files)
* Fix printing of constrained expressions in rhs of js objects [#240](https://github.com/rescript-lang/syntax/pull/240)
* Improve printing of trailing comments under lhs of "pipe" expression in [#329](https://github.com/rescript-lang/syntax/pull/239/files)
* Improve printing of jsx children and props with leading line comment in [#236](https://github.com/rescript-lang/syntax/pull/236)
* Improve conversion of quoted strings from Reason in [#238](https://github.com/rescript-lang/syntax/pull/238)
* Print attributes/extension without bs prefix where possible in [#230](https://github.com/rescript-lang/syntax/pull/230)
* Cleanup gentype attribute printing [fe05e1051aa94b16f6993ddc5ba9651f89e86907](https://github.com/rescript-lang/syntax/commit/fe05e1051aa94b16f6993ddc5ba9651f89e86907)
* Implement light weight syntax for poly-variants [f84c5760b3f743f65e934195c87fc06bf88bff75](https://github.com/rescript-lang/syntax/commit/f84c5760b3f743f65e934195c87fc06bf88bff75)
* Fix bug in fast pipe conversion from Reason. [3d5f2daba5418b821c577ba03e2de1afb0dd66de](https://github.com/rescript-lang/syntax/commit/3d5f2daba5418b821c577ba03e2de1afb0dd66de)
* Improve parsed AST when tilde is missing in arrow expr parameters. [e52a0c89ac39b578a2062ef15fae2be625962e1f](https://github.com/rescript-lang/syntax/commit/e52a0c89ac39b578a2062ef15fae2be625962e1f)
* Improve parser diagnostics for missing tilde in labeled parameters. [a0d7689d5d2bfc31dc251e966ac33a3001200171](https://github.com/rescript-lang/syntax/commit/a0d7689d5d2bfc31dc251e966ac33a3001200171)
* Improve printing of uncurried application with a huggable expression in [c8767215186982e171fe9f9101d518150a65f0d7](https://github.com/rescript-lang/syntax/commit/c8767215186982e171fe9f9101d518150a65f0d7)
* Improve printing of uncurried arrow typexpr outcome printer in [4d953b668cf47358deccb8b730566f24de25b9ee](https://github.com/rescript-lang/syntax/commit/4d953b668cf47358deccb8b730566f24de25b9ee)
* Remove support for nativeint syntax in [72d9b7034fc28f317672c94994b322bee520acca](https://github.com/rescript-lang/syntax/commit/72d9b7034fc28f317672c94994b322bee520acca)
* Improve printing of poly variant typexprs with attributes in [bf6561b](https://github.com/rescript-lang/syntax/commit/bf6561bb5d84557b8b6cbbcd40078c39526af4af)
- Fix printing for inline nullary functor types [#477](https://github.com/rescript-lang/syntax/pull/477)
- Fix stripping of quotes for empty poly variants [#474](https://github.com/rescript-lang/syntax/pull/474)
- Implement syntax for arity zero vs arity one in uncurried application in [#139](https://github.com/rescript-lang/syntax/pull/139)
- Fix parsing of first class module exprs as part of binary/ternary expr in [#256](https://github.com/rescript-lang/syntax/pull/256)
- Fix formatter hanging on deeply nested function calls [#261](https://github.com/rescript-lang/syntax/issues/261)
- Remove parsing of "import" and "export" which was never officially supported.

## ReScript 9.0.0

- Fix parsing of poly-var typexpr consisting of one tag-spec-first in [#254](https://github.com/rescript-lang/syntax/pull/254)
- Implement new syntax for guards on pattern match cases in [#248](https://github.com/rescript-lang/syntax/pull/248)
- Implement intelligent breaking for poly-var type expressions in [#246](https://github.com/rescript-lang/syntax/pull/246)
- Improve indentation of fast pipe chain in let binding in [#244](https://github.com/rescript-lang/syntax/pull/244)
- Improve printing of non-callback arguments in call expressions with callback in [#241](https://github.com/rescript-lang/syntax/pull/241/files)
- Fix printing of constrained expressions in rhs of js objects [#240](https://github.com/rescript-lang/syntax/pull/240)
- Improve printing of trailing comments under lhs of "pipe" expression in [#329](https://github.com/rescript-lang/syntax/pull/239/files)
- Improve printing of jsx children and props with leading line comment in [#236](https://github.com/rescript-lang/syntax/pull/236)
- Improve conversion of quoted strings from Reason in [#238](https://github.com/rescript-lang/syntax/pull/238)
- Print attributes/extension without bs prefix where possible in [#230](https://github.com/rescript-lang/syntax/pull/230)
- Cleanup gentype attribute printing [fe05e1051aa94b16f6993ddc5ba9651f89e86907](https://github.com/rescript-lang/syntax/commit/fe05e1051aa94b16f6993ddc5ba9651f89e86907)
- Implement light weight syntax for poly-variants [f84c5760b3f743f65e934195c87fc06bf88bff75](https://github.com/rescript-lang/syntax/commit/f84c5760b3f743f65e934195c87fc06bf88bff75)
- Fix bug in fast pipe conversion from Reason. [3d5f2daba5418b821c577ba03e2de1afb0dd66de](https://github.com/rescript-lang/syntax/commit/3d5f2daba5418b821c577ba03e2de1afb0dd66de)
- Improve parsed AST when tilde is missing in arrow expr parameters. [e52a0c89ac39b578a2062ef15fae2be625962e1f](https://github.com/rescript-lang/syntax/commit/e52a0c89ac39b578a2062ef15fae2be625962e1f)
- Improve parser diagnostics for missing tilde in labeled parameters. [a0d7689d5d2bfc31dc251e966ac33a3001200171](https://github.com/rescript-lang/syntax/commit/a0d7689d5d2bfc31dc251e966ac33a3001200171)
- Improve printing of uncurried application with a huggable expression in [c8767215186982e171fe9f9101d518150a65f0d7](https://github.com/rescript-lang/syntax/commit/c8767215186982e171fe9f9101d518150a65f0d7)
- Improve printing of uncurried arrow typexpr outcome printer in [4d953b668cf47358deccb8b730566f24de25b9ee](https://github.com/rescript-lang/syntax/commit/4d953b668cf47358deccb8b730566f24de25b9ee)
- Remove support for nativeint syntax in [72d9b7034fc28f317672c94994b322bee520acca](https://github.com/rescript-lang/syntax/commit/72d9b7034fc28f317672c94994b322bee520acca)
- Improve printing of poly variant typexprs with attributes in [bf6561b](https://github.com/rescript-lang/syntax/commit/bf6561bb5d84557b8b6cbbcd40078c39526af4af)

## ReScript 8.4.2 (December 11, 2020)

Expand Down
52 changes: 52 additions & 0 deletions src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ let uncurryAttr = (Location.mknoloc "bs", Parsetree.PStr [])
let ternaryAttr = (Location.mknoloc "ns.ternary", Parsetree.PStr [])
let ifLetAttr = (Location.mknoloc "ns.iflet", Parsetree.PStr [])
let optionalAttr = (Location.mknoloc "ns.optional", Parsetree.PStr [])
let makeAwaitAttr loc = (Location.mkloc "res.await" loc, Parsetree.PStr [])
let makeAsyncAttr loc = (Location.mkloc "res.async" loc, Parsetree.PStr [])

let makeExpressionOptional ~optional (e : Parsetree.expression) =
if optional then {e with pexp_attributes = optionalAttr :: e.pexp_attributes}
Expand Down Expand Up @@ -237,6 +239,9 @@ let rec goToClosing closingToken state =
(* Madness *)
let isEs6ArrowExpression ~inTernary p =
Parser.lookahead p (fun state ->
(match state.Parser.token with
| Lident "async" -> Parser.next state
| _ -> ());
match state.Parser.token with
| Lident _ | Underscore -> (
Parser.next state;
Expand Down Expand Up @@ -2031,6 +2036,16 @@ and parseOperandExpr ~context p =
let expr = parseUnaryExpr p in
let loc = mkLoc startPos p.prevEndPos in
Ast_helper.Exp.assert_ ~loc expr
| Lident "async"
(* we need to be careful when we're in a ternary true branch:
`condition ? ternary-true-branch : false-branch`
Arrow expressions could be of the form: `async (): int => stuff()`
But if we're in a ternary, the `:` of the ternary takes precedence
*)
when isEs6ArrowExpression ~inTernary:(context = TernaryTrueBranchExpr) p
IwanKaramazow marked this conversation as resolved.
Show resolved Hide resolved
->
parseAsyncArrowExpression p
| Await -> parseAwaitExpression p
| Lazy ->
Parser.next p;
let expr = parseUnaryExpr p in
Expand Down Expand Up @@ -2744,6 +2759,21 @@ and parseBracedOrRecordExpr p =
let expr = parseRecordExpr ~startPos [] p in
Parser.expect Rbrace p;
expr
(*
The branch below takes care of the "braced" expression {async}.
The big reason that we need all these branches is that {x} isn't a record with a punned field x, but a braced expression… There's lots of "ambiguity" between a record with a single punned field and a braced expression…
What is {x}?
1) record {x: x}
2) expression x which happens to wrapped in braces
Due to historical reasons, we always follow 2
*)
| Lident "async" when isEs6ArrowExpression ~inTernary:false p ->
IwanKaramazow marked this conversation as resolved.
Show resolved Hide resolved
let expr = parseAsyncArrowExpression p in
let expr = parseExprBlock ~first:expr p in
Parser.expect Rbrace p;
let loc = mkLoc startPos p.prevEndPos in
let braces = makeBracesAttr loc in
{expr with pexp_attributes = braces :: expr.pexp_attributes}
| Uident _ | Lident _ -> (
let startToken = p.token in
let valueOrConstructor = parseValueOrConstructor p in
Expand Down Expand Up @@ -3099,6 +3129,28 @@ and parseExprBlock ?first p =
Parser.eatBreadcrumb p;
overParseConstrainedOrCoercedOrArrowExpression p blockExpr

and parseAsyncArrowExpression p =
let startPos = p.Parser.startPos in
Parser.expect (Lident "async") p;
let asyncAttr = makeAsyncAttr (mkLoc startPos p.prevEndPos) in
let expr = parseEs6ArrowExpression p in
{
expr with
pexp_attributes = asyncAttr :: expr.pexp_attributes;
pexp_loc = {expr.pexp_loc with loc_start = startPos};
}

and parseAwaitExpression p =
let awaitLoc = mkLoc p.Parser.startPos p.endPos in
let awaitAttr = makeAwaitAttr awaitLoc in
Parser.expect Await p;
let expr = parseUnaryExpr p in
{
expr with
pexp_attributes = awaitAttr :: expr.pexp_attributes;
pexp_loc = {expr.pexp_loc with loc_start = awaitLoc.loc_start};
}

and parseTryExpression p =
let startPos = p.Parser.startPos in
Parser.expect Try p;
Expand Down
20 changes: 10 additions & 10 deletions src/res_grammar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ let isAtomicTypExprStart = function
| _ -> false

let isExprStart = function
| Token.True | False | Int _ | String _ | Float _ | Codepoint _ | Backtick
| Underscore (* _ => doThings() *)
| Uident _ | Lident _ | Hash | Lparen | List | Module | Lbracket | Lbrace
| LessThan | Minus | MinusDot | Plus | PlusDot | Bang | Percent | At | If
| Switch | While | For | Assert | Lazy | Try ->
| Token.Assert | At | Await | Backtick | Bang | Codepoint _ | False | Float _
| For | Hash | If | Int _ | Lazy | Lbrace | Lbracket | LessThan | Lident _
| List | Lparen | Minus | MinusDot | Module | Percent | Plus | PlusDot
| String _ | Switch | True | Try | Uident _ | Underscore (* _ => doThings() *)
| While ->
true
| _ -> false

Expand Down Expand Up @@ -255,11 +255,11 @@ let isAttributeStart = function
let isJsxChildStart = isAtomicExprStart

let isBlockExprStart = function
| Token.At | Hash | Percent | Minus | MinusDot | Plus | PlusDot | Bang | True
| False | Float _ | Int _ | String _ | Codepoint _ | Lident _ | Uident _
| Lparen | List | Lbracket | Lbrace | Forwardslash | Assert | Lazy | If | For
| While | Switch | Open | Module | Exception | Let | LessThan | Backtick | Try
| Underscore ->
| Token.Assert | At | Await | Backtick | Bang | Codepoint _ | Exception
| False | Float _ | For | Forwardslash | Hash | If | Int _ | Lazy | Lbrace
| Lbracket | LessThan | Let | Lident _ | List | Lparen | Minus | MinusDot
| Module | Open | Percent | Plus | PlusDot | String _ | Switch | True | Try
| Uident _ | Underscore | While ->
true
| _ -> false

Expand Down
16 changes: 15 additions & 1 deletion src/res_parens.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ let callExpr expr =
| Pexp_try _ | Pexp_while _ | Pexp_for _ | Pexp_ifthenelse _ );
} ->
Parenthesized
| _ when ParsetreeViewer.hasAwaitAttribute expr.pexp_attributes ->
Parenthesized
| _ -> Nothing)

let structureExpr expr =
Expand Down Expand Up @@ -96,6 +98,8 @@ let unaryExprOperand expr =
| Pexp_try _ | Pexp_while _ | Pexp_for _ | Pexp_ifthenelse _ );
} ->
Parenthesized
| _ when ParsetreeViewer.hasAwaitAttribute expr.pexp_attributes ->
Parenthesized
| _ -> Nothing)

let binaryExprOperand ~isLhs expr =
Expand All @@ -120,6 +124,8 @@ let binaryExprOperand ~isLhs expr =
| expr when ParsetreeViewer.isBinaryExpression expr -> Parenthesized
| expr when ParsetreeViewer.isTernaryExpr expr -> Parenthesized
| {pexp_desc = Pexp_lazy _ | Pexp_assert _} when isLhs -> Parenthesized
| _ when ParsetreeViewer.hasAwaitAttribute expr.pexp_attributes ->
Parenthesized
| {Parsetree.pexp_attributes = attrs} ->
if ParsetreeViewer.hasPrintableAttributes attrs then Parenthesized
else Nothing)
Expand Down Expand Up @@ -169,7 +175,7 @@ let flattenOperandRhs parentOperator rhs =
| _ when ParsetreeViewer.isTernaryExpr rhs -> true
| _ -> false

let lazyOrAssertExprRhs expr =
let lazyOrAssertOrAwaitExprRhs expr =
let optBraces, _ = ParsetreeViewer.processBracesAttr expr in
match optBraces with
| Some ({Location.loc = bracesLoc}, _) -> Braced bracesLoc
Expand All @@ -196,6 +202,8 @@ let lazyOrAssertExprRhs expr =
| Pexp_try _ | Pexp_while _ | Pexp_for _ | Pexp_ifthenelse _ );
} ->
Parenthesized
| _ when ParsetreeViewer.hasAwaitAttribute expr.pexp_attributes ->
Parenthesized
| _ -> Nothing)

let isNegativeConstant constant =
Expand Down Expand Up @@ -240,6 +248,8 @@ let fieldExpr expr =
| Pexp_ifthenelse _ );
} ->
Parenthesized
| _ when ParsetreeViewer.hasAwaitAttribute expr.pexp_attributes ->
Parenthesized
| _ -> Nothing)

let setFieldExprRhs expr =
Expand Down Expand Up @@ -302,6 +312,8 @@ let jsxPropExpr expr =
}
when startsWithMinus x ->
Parenthesized
| _ when ParsetreeViewer.hasAwaitAttribute expr.pexp_attributes ->
Parenthesized
| {
Parsetree.pexp_desc =
( Pexp_ident _ | Pexp_constant _ | Pexp_field _ | Pexp_construct _
Expand Down Expand Up @@ -338,6 +350,8 @@ let jsxChildExpr expr =
}
when startsWithMinus x ->
Parenthesized
| _ when ParsetreeViewer.hasAwaitAttribute expr.pexp_attributes ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of these. Should there be a generic concept of which this is an instance so all these calls are moved to a single place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give an example of what you mean by this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can move to a helper function, though the difference is minimal. Just easier to make sure all the instances are updated at once if something changes in future.

Another thing I was wondering is: this case seems to often go where there is also ParsetreeViewer.filterParsingAttrs attrs. But not always, so not sure what value this observation has.
But I guess in the cases where ParsetreeViewer.filterParsingAttrs attrs is checked, this await check could at least go right after it. Assuming that no cases in between should take precedence.

Parenthesized
| {
Parsetree.pexp_desc =
( Pexp_ident _ | Pexp_constant _ | Pexp_field _ | Pexp_construct _
Expand Down
2 changes: 1 addition & 1 deletion src/res_parens.mli
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ val subBinaryExprOperand : string -> string -> bool
val rhsBinaryExprOperand : string -> Parsetree.expression -> bool
val flattenOperandRhs : string -> Parsetree.expression -> bool

val lazyOrAssertExprRhs : Parsetree.expression -> kind
val lazyOrAssertOrAwaitExprRhs : Parsetree.expression -> kind

val fieldExpr : Parsetree.expression -> kind

Expand Down
38 changes: 32 additions & 6 deletions src/res_parsetree_viewer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let arrowType ct =
process attrsBefore (arg :: acc) typ2
| {
ptyp_desc = Ptyp_arrow ((Nolabel as lbl), typ1, typ2);
ptyp_attributes = [({txt = "bs"}, _)] as attrs;
ptyp_attributes = [({txt = "bs" | "res.async"}, _)] as attrs;
} ->
let arg = (attrs, lbl, typ1) in
process attrsBefore (arg :: acc) typ2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a separate case for process attributes?
Why not always process attributes and if nothing of interest is found then it's a no-op.
And the following match case disappears.

Expand Down Expand Up @@ -55,6 +55,30 @@ let processUncurriedAttribute attrs =
in
process false [] attrs

type functionAttributesInfo = {
async: bool;
uncurried: bool;
attributes: Parsetree.attributes;
}

let processFunctionAttributes attrs =
let rec process async uncurried acc attrs =
match attrs with
| [] -> {async; uncurried; attributes = List.rev acc}
| ({Location.txt = "bs"}, _) :: rest -> process async true acc rest
| ({Location.txt = "res.async"}, _) :: rest ->
process true uncurried acc rest
| attr :: rest -> process async uncurried (attr :: acc) rest
in
process false false [] attrs

let hasAwaitAttribute attrs =
List.exists
(function
| {Location.txt = "res.await"}, _ -> true
| _ -> false)
attrs

let collectListExpressions expr =
let rec collect acc expr =
match expr.pexp_desc with
Expand Down Expand Up @@ -168,8 +192,9 @@ let filterParsingAttrs attrs =
match attr with
| ( {
Location.txt =
( "ns.ternary" | "ns.braces" | "res.template" | "bs" | "ns.iflet"
| "ns.namedArgLoc" | "ns.optional" );
( "bs" | "ns.braces" | "ns.iflet" | "ns.namedArgLoc"
| "ns.optional" | "ns.ternary" | "res.async" | "res.await"
| "res.template" );
},
_ ) ->
false
Expand Down Expand Up @@ -316,7 +341,8 @@ let hasAttributes attrs =
match attr with
| ( {
Location.txt =
"bs" | "res.template" | "ns.ternary" | "ns.braces" | "ns.iflet";
( "bs" | "ns.braces" | "ns.iflet" | "ns.ternary" | "res.async"
| "res.await" | "res.template" );
},
_ ) ->
false
Expand Down Expand Up @@ -497,8 +523,8 @@ let isPrintableAttribute attr =
match attr with
| ( {
Location.txt =
( "bs" | "res.template" | "ns.ternary" | "ns.braces" | "ns.iflet"
| "JSX" );
( "bs" | "ns.iflet" | "ns.braces" | "JSX" | "res.async" | "res.await"
| "res.template" | "ns.ternary" );
},
_ ) ->
false
Expand Down
11 changes: 11 additions & 0 deletions src/res_parsetree_viewer.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ val functorType :
val processUncurriedAttribute :
Parsetree.attributes -> bool * Parsetree.attributes

type functionAttributesInfo = {
async: bool;
uncurried: bool;
attributes: Parsetree.attributes;
}

(* determines whether a function is async and/or uncurried based on the given attributes *)
val processFunctionAttributes : Parsetree.attributes -> functionAttributesInfo

val hasAwaitAttribute : Parsetree.attributes -> bool

type ifConditionKind =
| If of Parsetree.expression
| IfLet of Parsetree.pattern * Parsetree.expression
Expand Down
Loading