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

Empty paren in expression throws TypeError #58

Closed
oaleynik opened this issue Feb 10, 2015 · 7 comments
Closed

Empty paren in expression throws TypeError #58

oaleynik opened this issue Feb 10, 2015 · 7 comments

Comments

@oaleynik
Copy link

The following example crashes eslint (caused by the last line in the file):

var left, aSize, bSize;

aSize = {
  width: 800,
  height: 600
};

bSize = {
  width: 200,
  height: 100
};

left = (aSize.width/2) - ()

with error

eslint test.js

/home/julien/.nvm/v0.10.30/lib/node_modules/eslint/lib/token-store.js:181
            starts[right.range[0]] + padding
                              ^
TypeError: Cannot read property '0' of undefined
    at EventEmitter.api.getTokensBetween (/home/julien/.nvm/v0.10.30/lib/node_modules/eslint/lib/token-store.js:181:31)
    at RuleContext.(anonymous function) [as getTokensBetween] (/home/julien/.nvm/v0.10.30/lib/node_modules/eslint/lib/rule-context.js:82:33)
    at isSpaced (/home/julien/.nvm/v0.10.30/lib/node_modules/eslint/lib/rules/space-infix-ops.js:21:34)
    at EventEmitter.checkBinary (/home/julien/.nvm/v0.10.30/lib/node_modules/eslint/lib/rules/space-infix-ops.js:40:14)
    at EventEmitter.emit (events.js:117:20)
    at Controller.controller.traverse.enter (/home/julien/.nvm/v0.10.30/lib/node_modules/eslint/lib/eslint.js:673:25)
    at Controller.__execute (/home/julien/.nvm/v0.10.30/lib/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/home/julien/.nvm/v0.10.30/lib/node_modules/eslint/node_modules/estraverse/estraverse.js:495:28)
    at EventEmitter.module.exports.api.verify (/home/julien/.nvm/v0.10.30/lib/node_modules/eslint/lib/eslint.js:666:24)
    at processFile (/home/julien/.nvm/v0.10.30/lib/node_modules/eslint/lib/cli-engine.js:172:27)

Looks like parentheses in the end of the line left = (aSize.width / 2) - () treated as ArrowParameterPlaceHolder

https://www.dropbox.com/s/0oltkd0vbdo0iew/Screenshot%202015-02-10%2018.51.52.png?dl=0

eslint/eslint#1816
AtomLinter/linter-eslint#28

@nzakas
Copy link
Member

nzakas commented Feb 10, 2015

@xjamundx do you want to take a look at this?

@xjamundx
Copy link
Contributor

Will totally check this out. Though here's what I'm seeing in Chrome with the same code:
screen shot 2015-02-10 at 12 28 39 pm

Also some weird stuff here in the result:
http://esprima.org/demo/parse.html?code=left%20%3D%20(aSize.width%2F2)%20-%20()

I suppose the expected behavior is "not crash" though :)

@oaleynik
Copy link
Author

@xjamundx if run eslint with --rule {"arrowFunctions": false} - it runs nicely, eslint reports Unexpected token ) as expected, but with default settings it's crashing

@xjamundx
Copy link
Contributor

FYI this was solved in the destructuring PR

@xjamundx
Copy link
Contributor

I'll write some tests to ensure it

@xjamundx
Copy link
Contributor

When I set config.parser to the path of the master of espree and run eslint I see:
screen shot 2015-02-10 at 1 48 05 pm

@nzakas
Copy link
Member

nzakas commented Feb 10, 2015

Ooh nice, thanks for the update.

@nzakas nzakas closed this as completed Feb 10, 2015
xjamundx pushed a commit to xjamundx/espree that referenced this issue Feb 10, 2015
nzakas added a commit that referenced this issue Feb 11, 2015
Test: incorrectly parsed arrow fragment (refs #58)
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