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

Commit 41844e6

Browse files
author
Maxim
committed
Document ternary colon vs async arrow expression colon
1 parent 046d1e3 commit 41844e6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/res_core.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,6 +2037,11 @@ and parseOperandExpr ~context p =
20372037
let loc = mkLoc startPos p.prevEndPos in
20382038
Ast_helper.Exp.assert_ ~loc expr
20392039
| Lident "async"
2040+
(* we need to be careful when we're in a ternary true branch:
2041+
`condition ? ternary-true-branch : false-branch`
2042+
Arrow expressions could be of the form: `async (): int => stuff()`
2043+
But if we're in a ternary, the `:` of the ternary takes precedence
2044+
*)
20402045
when isEs6ArrowExpression ~inTernary:(context = TernaryTrueBranchExpr) p
20412046
->
20422047
parseAsyncArrowExpression p

0 commit comments

Comments
 (0)