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

Catchless try statement linter crash #97

Closed
wcjohnson opened this issue Sep 27, 2018 · 2 comments
Closed

Catchless try statement linter crash #97

wcjohnson opened this issue Sep 27, 2018 · 2 comments

Comments

@wcjohnson
Copy link
Owner

try:
  y

Gives

TypeError: Cannot read property 'empty' of null
    at CodePathState.popTryContext (/Users/wcj/dev/lightscript-minimal-node/node_modules/eslint/lib/code-path-analysis/code-path-state.js:755:22)
    at processCodePathToExit (/Users/wcj/dev/lightscript-minimal-node/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:481:19)
    at CodePathAnalyzer.leaveNode (/Users/wcj/dev/lightscript-minimal-node/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:651:9)
    at nodeQueue.forEach.traversalInfo (/Users/wcj/dev/lightscript-minimal-node/node_modules/eslint/lib/linter.js:862:28)
    at Array.forEach (<anonymous>)
    at runRules (/Users/wcj/dev/lightscript-minimal-node/node_modules/eslint/lib/linter.js:856:15)
    at Linter._verifyWithoutProcessors (/Users/wcj/dev/lightscript-minimal-node/node_modules/eslint/lib/linter.js:992:31)
    at preprocess.map.textBlock (/Users/wcj/dev/lightscript-minimal-node/node_modules/eslint/lib/linter.js:1043:35)
    at Array.map (<anonymous>)
    at Linter.verify (/Users/wcj/dev/lightscript-minimal-node/node_modules/eslint/lib/linter.js:1042:42)

Essentially, eslint is expecting every try to have a catch or finally, since that's the rule in JS. This part of the linter is not easily extensible, so the solution probably involves doing an ast transform in the parser to add a faux catch block.

@wcjohnson
Copy link
Owner Author

See: eslint/eslint#10823

@wcjohnson
Copy link
Owner Author

Upon evaluating this, I think this is a parser bug. Technically the ESTree spec says a TryStatement needs either a catch or finally, so when the parser emits one without that, it's emitting faulty nodes.

So, will resolve by having the parser emit an LscTryStatement if there is no catch or finally, then just transform that into a regular try statement in the compiler.

@wcjohnson wcjohnson added parser and removed linter labels Oct 3, 2018
wcjohnson added a commit to wcjohnson/lightscript-eslint that referenced this issue Oct 3, 2018
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

1 participant