Skip to content

Parse async arrows outside guards again - #8941

Merged
cknitt merged 1 commit into
masterfrom
async-guard-only
Oct 21, 2026
Merged

cknitt merged 1 commit into
masterfrom
async-guard-only

Conversation

@cknitt

@cknitt cknitt commented Oct 21, 2026

Copy link
Copy Markdown
Member

Follow-up to #8935, addressing its Codex review comment that came in after the merge.

#8935 skipped the async arrow lookahead in every WhenExpr position, but WhenExpr is also used for the switch scrutinee and the try body, which can be of any type. So

let scrutinee = switch async () => 1 {
| _ => 0
}

stopped 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:

No changelog fragment: #8935's fragment is not released yet, and this only narrows that unreleased change.

Test: parsing/grammar/expressions/async.res gets an async arrow as switch scrutinee and a parenthesized guard.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fc7LEuyEfynjaKCVEBPmTF

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]>
@cknitt cknitt added the changelog:skip No release notes needed label Oct 21, 2026
@github-actions

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.14%. Comparing base (38ba55a) to head (f8805a4).
⚠️ Report is 3 commits behind head on master.

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           
Files with missing lines Coverage Δ
compiler/syntax/src/res_core.ml 91.99% <100.00%> (+<0.01%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Oct 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8941

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8941

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8941

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8941

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8941

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8941

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8941

commit: f8805a4

@github-actions

Copy link
Copy Markdown

@cknitt

cknitt commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T12:54:01.155701Z f8805a4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: f8805a4bfc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@cknitt
cknitt marked this pull request as ready for review October 21, 2026 12:58
@cknitt
cknitt requested a review from cristianoc October 21, 2026 12:59
@cknitt
cknitt merged commit 5671fc4 into master Oct 21, 2026
28 of 29 checks passed
@cknitt
cknitt deleted the async-guard-only branch October 21, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skip No release notes needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants