Repository navigation
Parse async arrows outside guards again - #8941
Conversation
Why:
#8935 suppressed the async arrow lookahead in every `WhenExpr`
position, so an async arrow as a switch scrutinee or try body no
longer parsed. Only guards are followed by the case's `=>`.
Guards now have their own parsing context, in which both async and
plain arrows are suppressed; other `WhenExpr` positions suppress plain
arrows only, as before #8935.
AST modified (switch scrutinee):
Example:
let scrutinee = switch async () => 1 {
| _ => 0
}
Before (diagnostic):
Did you forget a `{` here?
After (expanded):
let scrutinee = match async fun [arity:1]() -> 1 with | _ -> 0
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fc7LEuyEfynjaKCVEBPmTF
Signed-off-by: Christoph Knittel <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8941 +/- ##
=======================================
Coverage 81.14% 81.14%
=======================================
Files 456 456
Lines 63760 63773 +13
=======================================
+ Hits 51738 51751 +13
Misses 12022 12022
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-8941 |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Follow-up to #8935, addressing its Codex review comment that came in after the merge.
#8935 skipped the async arrow lookahead in every
WhenExprposition, butWhenExpris also used for the switch scrutinee and thetrybody, which can be of any type. Sostopped parsing ("Did you forget a
{here?"). Only a guard is followed by the case's own=>, so guards now get their own parsing context,GuardExpr:| Some(x) if async(x) => …and| Some(x) if (x) => …stay guards.WhenExprpositions, only plain arrows are skipped, as before Parse a switch guard that calls a function named async #8935.No changelog fragment: #8935's fragment is not released yet, and this only narrows that unreleased change.
Test:
parsing/grammar/expressions/async.resgets an async arrow as switch scrutinee and a parenthesized guard.🤖 Generated with Claude Code
https://claude.ai/code/session_01Fc7LEuyEfynjaKCVEBPmTF