Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

espree erroneously complains about arrow function #145

Closed
tromey opened this issue May 26, 2015 · 6 comments
Closed

espree erroneously complains about arrow function #145

tromey opened this issue May 26, 2015 · 6 comments
Assignees

Comments

@tromey
Copy link

tromey commented May 26, 2015

This fails to parse, but I think it should succeed:

pokyo. node
> require('espree').parse('(a, b=(c)=>c) => {}', {ecmaFeatures: { arrowFunctions: true }})
Error: Line 1: Unexpected token =>
    at throwError (/home/tromey/node_modules/espree/espree.js:2069:17)
    at throwUnexpected (/home/tromey/node_modules/espree/espree.js:2132:5)
    at consumeSemicolon (/home/tromey/node_modules/espree/espree.js:2213:9)
    at parseExpressionStatement (/home/tromey/node_modules/espree/espree.js:3719:5)
    at parseStatement (/home/tromey/node_modules/espree/espree.js:4242:44)
    at parseSourceElement (/home/tromey/node_modules/espree/espree.js:5128:16)
    at parseSourceElements (/home/tromey/node_modules/espree/espree.js:5161:25)
    at parseProgram (/home/tromey/node_modules/espree/espree.js:5181:12)
    at Object.parse (/home/tromey/node_modules/espree/espree.js:5423:19)
    at repl:1:20

SpiderMonkey's Reflect.parse works on this, though I realize this is not completely definitive.

@xjamundx
Copy link
Contributor

Yeah it passes babel's parser as well.

@xjamundx
Copy link
Contributor

I'll try to take a stab at this as well...

@xjamundx xjamundx self-assigned this Aug 11, 2015
@xjamundx
Copy link
Contributor

These are all fine

require('./').parse('(a, b=()=>{}) => {}', {ecmaFeatures: { arrowFunctions: true, defaultParams: true }})
require('./').parse('(a, b=c=>{}) => {}', {ecmaFeatures: { arrowFunctions: true, defaultParams: true }})
require('./').parse('(a, b=c=>c) => {}', {ecmaFeatures: { arrowFunctions: true, defaultParams: true }})

These variations are not:

require('./').parse('(a, b=(c,d)=>c) => {}', {ecmaFeatures: { arrowFunctions: true, defaultParams: true }})
require('./').parse('(a, b=(c)=>{}) => {}', {ecmaFeatures: { arrowFunctions: true, defaultParams: true }})
require('./').parse('(a, b=(c)=>c) => {}', {ecmaFeatures: { arrowFunctions: true, defaultParams: true }})

@xjamundx
Copy link
Contributor

So far no progress, poking around still. Hoping to figure it out.

@xjamundx
Copy link
Contributor

Getting closer....the one case is getitng intepretted as a SequenceExpression somewhere..

@xjamundx
Copy link
Contributor

Sweet I got a passing test. Super sketchy code, but I'll work on it a bit and get this fixed!

xjamundx pushed a commit to xjamundx/espree that referenced this issue Aug 12, 2015
@nzakas nzakas closed this as completed in ee4ea43 Aug 13, 2015
nzakas added a commit that referenced this issue Aug 13, 2015
Fix: Various Arrow Function Issues (fixes #187, fixes #145 and fixes #172)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants