Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Parsing error of generic function when enabling jsx and flow plugins #471

Closed
tibdex opened this issue Apr 14, 2017 · 3 comments · Fixed by #475
Closed

Parsing error of generic function when enabling jsx and flow plugins #471

tibdex opened this issue Apr 14, 2017 · 3 comments · Fixed by #475

Comments

@tibdex
Copy link

tibdex commented Apr 14, 2017

I found this while using prettier 1.1.0.

Input Code

const identity = <T>(t: T): T => t;
const a = 1;

Babylon/Babel Configuration

{
  plugins: ['jsx', 'flow']
}

Expected Behavior

The code is valid and babylon should be able to parse it.

Current Behavior

babylon throws Unexpected token (2:0). You can see it live on the prettier playground.

Removing the jsx plugin and only enabling the flow one makes babylon able to parse the code correctly.

Your Environment

software version
Babylon 7.0.0-beta.8
node 6.9.1
yarn 0.22.0
Operating System Windows 10
@hzoo
Copy link
Member

hzoo commented Apr 14, 2017

Hey @tibdex! 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.

@tibdex
Copy link
Author

tibdex commented Apr 14, 2017

Thanks @hzoo, of course no hurry :) ! I just thought that since the issue is impacting the latest release of prettier lot of people were going to stumble into it. So I just went ahead and created a ticket here and on the prettier repo so that people also experiencing it can see that there is already an issue for it.

@tibdex
Copy link
Author

tibdex commented Apr 19, 2017

FYI I used git bisect and the issue appeared in 32eabf6.

Putting the code back as it was before #405 fixes the parsing error but seems to put back the code in a incorrect state if #404 is legit. Indeed, I added console.log statements before this.state.context.push(ct.parenExpression); and this.state.context.pop(); and here is the sequence:

push // 1
push // 2
pop // 1
push // 2
pop // 1
push // 2
pop // 1, missing a "pop" if the counter is expected to go back to 0, but is it ? ...

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

Successfully merging a pull request may close this issue.

3 participants