Visitar URL original
Improve F# pipeline direct body check by JLHwung · Pull Request #17806 · babel/babel · GitHub
Skip to content

Improve F# pipeline direct body check - #17806

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

nicolo-ribaudo merged 6 commits into
babel:mainfrom
JLHwung:improve-fsharp-direct-body-check

Conversation

@JLHwung

@JLHwung JLHwung commented Feb 17, 2026 •

Copy link
Copy Markdown
Contributor
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

babel-bot commented Feb 17, 2026 •

Copy link
Copy Markdown
Collaborator

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

pkg-pr-new Bot commented Feb 17, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

commit: c625231

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

@liuxingbaoyu liuxingbaoyu left a comment

Copy link
Copy Markdown
Member

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

@nicolo-ribaudo nicolo-ribaudo left a comment

Copy link
Copy Markdown
Member

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
@github-actions github-actions Bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 28, 2026
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 28, 2026
@babel-bot

Copy link
Copy Markdown
Collaborator

Backported to 7.x in #18450.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue 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