Skip to content

Improve F# pipeline direct body check#17806

Merged
nicolo-ribaudo merged 6 commits intobabel:mainfrom
JLHwung:improve-fsharp-direct-body-check
Feb 27, 2026
Merged

Improve F# pipeline direct body check#17806
nicolo-ribaudo merged 6 commits intobabel:mainfrom
JLHwung:improve-fsharp-direct-body-check

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Feb 17, 2026

Q                       A
Fixed Issues? Babel can not parse some valid F-sharp pipeline examples within an arrow body. (REPL)
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR contains commits from #17803. Please review that PR first.

Previously we used a tokenizer state inFSharpPipelineDirectBody to track whether |> is seen within the direct body of an F# pipeline. The state is reset when we are parsing parenthesis / arrow, call arguments / async arrow, array and object literal.

The reset is not complete as it does not cover the following cases: block statement, function body, parameter initializer, computed property, template quasis, static block, etc. All of them can host AssignmentExpression, and thus can host a new pipeline expression. But because the state is not reset, the parser will stop at the |>, resulting to unexpected parsing errors.

In this PR we track the FSharpPiplelineBody in the production parameter handler. A PARAM_NOT_FSHARP_PIPELINE_DIRECT_BODY parameter is introduced and associated with most parameter scopes: Specifically, this parameter is enabled when we parse an AssignmentExpression[+In], AssignmentExpression[~In]. The FSharpPipelineBody parsing routine disables this flag, and the ConciseBody will inherit this flag from the upper scope.

The new approach passes all previous test cases as well as new test cases on which the main is currently failing. We also removed the now unused tokenizer state inFSharpPipelineDirectBody.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: parser Spec: Pipeline Operator labels Feb 17, 2026
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Feb 17, 2026

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61021

@JLHwung JLHwung force-pushed the improve-fsharp-direct-body-check branch from c302c89 to 72bfeee Compare February 17, 2026 16:59
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 17, 2026

Open in StackBlitz

commit: c625231

@JLHwung JLHwung marked this pull request as ready for review February 17, 2026 17:39
Copy link
Copy Markdown
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

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

Great!

@JLHwung JLHwung added PR: Bug Fix (next major) 🐛 A type of pull request used for our changelog categories for next major release and removed PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Feb 24, 2026
@JLHwung JLHwung force-pushed the improve-fsharp-direct-body-check branch from 3dcf4c5 to d2c784c Compare February 24, 2026 21:37
@JLHwung JLHwung force-pushed the improve-fsharp-direct-body-check branch from 468cda1 to c625231 Compare February 25, 2026 15:37
Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

Very nice :)

@nicolo-ribaudo nicolo-ribaudo merged commit 9f94c18 into babel:main Feb 27, 2026
55 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the improve-fsharp-direct-body-check branch February 27, 2026 16:46
@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories PR: Bug Fix (next major) 🐛 A type of pull request used for our changelog categories for next major release Spec: Pipeline Operator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants