Skip to content

Wrong AST for conditional that looks like arrow #2006

@danez

Description

@danez

I noticed a bug in flow with this snippet, while trying to fix the same bug in babel/babylon.

let y = a ? (b) : c => d;

Flow creates an ast that looks like this:

VariableDeclerator
    -> ConditionalExpression
        -> consequent: ArrowFunctionExpression((b) : c => d)
        -> alternate: Literal(null)

but it should be

VariableDeclerator
    -> ConditionalExpression
        -> consequent: Identifier(b)
        -> alternate: ArrowFunctionExpression(c => d)

Tested with flow-parser 0.26 (the latest version on npm)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions