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
Could not traverse ClassPrivateMethod when estree plugin enabled #9506
Comments
Hey @coderaiser! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
Anyway, this inconsistency between public and private methods should be fixed. Demo: https://astexplorer.net/#/gist/3264a96e825cb7114c07221e47c08471/8b4e4ed7563e05cd0fbbdd4f5e7f15b6936f167b Public methods are made ESTree-compatible at https://github.com/babel/babel/blob/master/packages/babel-parser/src/plugins/estree.js#L200. We should do the same thing, but first estree/estree#180 should be merged. |
We will need to update |
@nicolo-ribaudo @coderaiser I’m a bit confused as it was said that the issue was fixed but I’m still getting it. Is it fixed in master but wasn’t yet released? |
No, It has been worked around in a separate repo. It still need to be fixed in Babel, but we are blocked by estree/estree#180 |
@satazor you can use estree-to-babel to have ability to use |
@coderaiser I'm getting this error in the context of https://github.com/babel/babel-eslint. Is there any way to use |
@satazor |
Sorry, I just found out |
Trying to resolve this for #9506, and it sounds like we need to decide what our policy is re experimental features and ESTree. The ESTree spec generally doesn't add language features until they hit stage 4 (see estree/estree#204 as an example). Waiting for the ESTree spec makes the How do we want to proceed? This is actually a big part of why ESLint core doesn't support experimental features - it would mean we would have to change any differences in ASTs if they're different when they're finalized. Seems like the ideal way forward would be for ESTree to develop working/living specs for experimental features, and then we could update our semver policy for the |
I propose this policy:
I think that we should never have an AST node which is neither Babel's AST nor ESTree: we don't need a new AST format. |
Wanted to check in with others who might be more knowledgeable about this. This error is thrown during the initial parsing, and I'm not seeing a way to easily access the |
Does |
I've actually been trying to track this down, because I was confused by this too. It looks like it does do some scope analysis at parse time. Here's a stack trace I logged by manually throwing an error when the at new Scope (/Users/kai/Code/babel/packages/babel-traverse/lib/scope/index.js:174:17)
at NodePath.getScope (/Users/kai/Code/babel/packages/babel-traverse/lib/path/index.js:122:29)
at NodePath.setScope (/Users/kai/Code/babel/packages/babel-traverse/lib/path/context.js:130:21)
at NodePath.setContext (/Users/kai/Code/babel/packages/babel-traverse/lib/path/context.js:147:8)
at new File (/Users/kai/Code/babel/packages/babel-core/lib/transformation/file/file.js:106:8)
at normalizeFile (/Users/kai/Code/babel/packages/babel-core/lib/transformation/normalize-file.js:151:10)
at parseSync (/Users/kai/Code/babel/packages/babel-core/lib/parse.js:56:37)
at parse (/Users/kai/Code/babel/eslint/babel-eslint-parser/src/parse.js:10:11)
at _default (/Users/kai/Code/babel/eslint/babel-eslint-parser/src/parse-with-scope.js:6:15)
at Object.parseForESLint (/Users/kai/Code/babel/eslint/babel-eslint-parser/src/index.js:25:10 For reference, this is where the error is thrown. |
Ok, calling |
Yeah, that makes sense to me. I'll keep digging and see if we need to update |
I have the same problem in Is this fixed with #10914? |
The error here should be fixed, yes! |
Bug Report
Current Behavior
When I'm using
estree
andclassPrivateMethods
and try to traverseClassPrivateMethod
I get crash:Input Code
Expected behavior/code
I expected no crash, regular traverse. Some time ago everything worked good, but after update everything is broke.
Environment
@babel/parser
:v7.3.2
@babel/traverse
:v7.2.3
Possible Solution
params
is empty inClassPrivateMethod
so path.get('params') returns single path, not an array.MethodDefinition
also has noparams
but it works good and not processed by this code.The text was updated successfully, but these errors were encountered: