-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
No need for parens for new expressions without args #3111
Conversation
Current coverage is
|
I would not of found those other edge cases - I wonder if there could be a tool that searches through codebases prints out the different types of AST to look for these. I guess you can also try to generate code from the spec but I would have even less idea about that? |
One thing to do is to check how existing tools do this. I went through uglify's code and it seems like we're handling everything they're handling. |
Ah yeah I guess that works as a baseline - unless they are messing up something as well. I remember sebmck mentioning everything.js in an old issue (found it: https://phabricator.babeljs.io/T2191) which has some other forms - https://github.com/michaelficarra/everything.js/blob/9bdd8a0a9fd571ecca612d53d417890e5a9409d4/es5.js#L77-L80 |
Ah that's useful. I can do some more testing using that |
Yeah don't need all of those but with new X();
new Y()();
new F().z;
new x();
new new x()();
new x[0]();
new x.a();
new x[0].a();
new x.a[0]();
new x;
new new x;
new new x();
new new x().a;
new new x()[0]; I get new X;new Y()();new F().z;
new x;new new x;new x[0];new x.a;new x[0].a;new x.a[0];
new x;new new x;new new x;new new x().a;new new x()[0]; |
looks correct? |
Yeah looks good |
@amasad Some test cases that produce incorrect results: new new x()(a);
new new x()()();
new new x()(a)();
new new x()()(a);
new new x()(a)(a); Produces new new x(a);new new x()();new new x(a)();new new x()(a);new new x(a)(a); All those have empty parens first so it's possible they are all the same edge case. |
Ok |
new new x()();
new new x()(a);
new new x(a)();
new new x(a)(a);
new new x;new new x()(a);new new x(a);new new x(a)(a); |
No need for parens for new expressions without args
Added the other commit in 21f7665 |
Actually I'm not sure how we would do this for multiple calls of new (my patch only works for Who would do even Maybe it would be better to just not do anything for multiple nested |
Talked with @amasad - just going to |
No description provided.