babel / babylon

PSA: moved into babel/babel as @babel/parser -->

Home Page:https://github.com/babel/babel/tree/master/packages/babel-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected AST for pipeline operator with arrow function

azz opened this issue · comments

Input Code

foo
  |> _ => a
  |> b

Babylon Configuration

{ "plugins": ["pipelineOperator"] }

Expected Behavior

As shown in the explainer, we should be able to use arrow functions without parens.

AST:

BinaryExpression (operator: "|>")
  left:
    Indentifier (id: "foo")
  right: 
    BinaryExpression (operator: "|>")
      left:
        ArrowFunctionExpression (params: [Identifier (name: "_")])
          body:
        Identifier (id: "a")
      right:
        Identifier (id: "b")

Current Behavior

Babylon is parsing the |> b as if it belonged to the arrow function, i.e. _ => (a |> b).

BinaryExpression (operator: "|>")
  left:
    Indentifier (id: "foo")
  right: 
    ArrowFunctionExpression (params: [Identifier (name: "_")])
      body:
        BinaryExpression (operator: "|>")
          left:
            Identifier (id: "a")
          right:
            Identifier (id: "b")

Your Environment

software version
Babylon 7.0.0-beta.28
node 6.11.0
npm 3.10.10
Operating System macOS 10.12.5
commented

Hey @azz! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

This issue has been moved to babel/babel#6669.