Repository navigation
Conversation
Why:
The async arrow lookahead also ran in guards, where the case's `=>`
follows the guard, so `if async(x) =>` was read as an async arrow.
Async arrows now skip the lookahead in the positions where other arrows
already do: guards and conditions. Fixes #8933.
AST modified (switch guard):
Example:
let async = x => x > 0
let f = v =>
switch v {
| Some(x) if async(x) => 1
| _ => 0
}
Before (diagnostic):
Did you forget a `=>` here?
After (expanded):
let f [arity:1]v =
match v with
| Some x when async x -> 1
| _ -> 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 #8935 +/- ##
=======================================
Coverage 81.13% 81.13%
=======================================
Files 456 456
Lines 63754 63754
=======================================
Hits 51728 51728
Misses 12026 12026
🚀 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-8935 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8933.
To tell an async arrow (
async (x) => …) apart from a call (async(x)), the parser looks ahead for=>after the parentheses. In a switch guard, the case's own=>follows the guard, sowas taken as the start of an async arrow and failed with "Did you forget a
=>here?".Ordinary arrows already skip this lookahead in guards and conditions (the
WhenExprcontext); async arrows now do the same. An arrow is never valid in those positions, since guards and conditions arebool.This matters beyond
async: the generator RFC (#8934) proposesgenas a contextual prefix that works the same way, andgenis a common function name.Test:
parsing/grammar/expressions/async.resgets a guard that callsasync(x)and async arrows as case bodies.🤖 Generated with Claude Code
https://claude.ai/code/session_01Fc7LEuyEfynjaKCVEBPmTF