-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
error on 'x++.toString()' #1208
Comments
@strager Could you please assign this to me? |
@strager This seems to be a more general issue when using a "member of" dot operator or a let x = 3;
console.log((x--).valueOf()); // Works fine, prints "3"
console.log((x--).constructor); // Works fine, prints "ƒ Number()"
console.log((x--)?.constructor); // Works fine, prints "ƒ Number()"
console.log(x--.valueOf()); // Invalid syntax
console.log(x--.constructor); // Invalid syntax
console.log(x--?.constructor); // Invalid syntax |
This diagnostic reports an error when `.` or `?.` directly follows `++` or `--`. Error message recommends adding parentheses around the postfix expression. This closes issue quick-lint#1208. quick-lint#1208
@strager This PR fixes the issue. I am also going to look for any other operators that cause a similar issue when placed after |
@strager After poking around a bit, it looks like there are a number of operators and other tokens that cause a syntax error when placed after
x++ (y);
x++ [y];
x++ .y;
x++ ?.y;
x++ new Type();
x++ ++y;
x++ --y;
x++ !y; // Also reports E0261
x++ typeof y;
x++ void(y);
x++ delete(y);
x++ yield y;
x++ yield* y;
x++ ~y;
x++ : y; // Also reports E0027
x++ ...y;
x++ = y;
x++ += y;
x++ -= y;
x++ *= y;
x++ **= y;
x++ /= y;
x++ %= y;
x++ <<= y;
x++ >>= y;
x++ >>>= y;
x++ &= y;
x++ |= y;
x++ ^= y;
x++ &&= y;
x++ ||= y;
x++ => y; The cases that report E0020, E0027, and E0151 make sense, while the rest probably need to be fixed. |
x++.toString()
seems to be invalid JS. Reject it and suggest parentheses.The text was updated successfully, but these errors were encountered: