Skip to content
This repository was archived by the owner on May 19, 2018. It is now read-only.
/ babylon Public archive
This repository was archived by the owner on May 19, 2018. It is now read-only.

Significant but hard-to-find bug in parsing arrow functions #58

@Lucretiel

Description

@Lucretiel

As of a recent release (Don't know when, exactly, but this issue broke code that was working fine around June 4), babylon's parsing of arrow functions has broken in a very peculiar way. When babylon encounters the following pattern:

<some expression> :
    <a parenthesized arrow expression> ?
    <an unparenthesized arrow expression>

It reports an error parsing the parenthesized arrow expression:

Module build failed: SyntaxError: <path to file>: Assigning to rvalue (23:3)

For example:

let x = foo() ?
    (value => true) :
    value => false

The contents of the condition don't seem to matter, nor does parenthesizing the entire conditional expression. However, if the parenthesis around the first arrow function are removed, or parenthesis are added to the second arrow function, or either arrow function is something other than an arrow function, it is parsed fine. This specific pattern is the only one that triggers the error.

For what it's worth, I'm running babylon via babel via webpack, but the stack trace I get is entirely from babylon.

This seems implausible, I know, so I've created a git repo which reproduces the error, available here:

https://github.com/Lucretiel/babylon-error

The specific file I'm trying to pack is index.js with no dependencies or requires. The raw output from webpack is in build_result.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions