Add parenthesis around binary expression inside of update expression (#1672)
This is not valid code but TypeScript parses it. It's easy to fix so might as well so we have one less failing test.
This commit is contained in:
1 parent
2512497288
commit
fc88aa185b
3 files changed
+120
No files matched your search
@@ -295,6 +295,10 @@ FPp.needsParens = function() {
|
||||
}
|
||||
|
||||
case "BinaryExpression": {
|
||||
if (parent.type === "UpdateExpression") {
|
||||
return true;
|
||||
}
|
||||
|
||||
const isLeftOfAForStatement = node => {
|
||||
let i = 0;
|
||||
while (node) {
|
||||
|
||||
@@ -214,6 +214,85 @@ interface i2 {
|
||||
|
||||
`;
|
||||
|
||||
exports[`decrementAndIncrementOperators.ts 1`] = `
|
||||
var x = 0;
|
||||
|
||||
// errors
|
||||
1 ++;
|
||||
|
||||
(1)++;
|
||||
(1)--;
|
||||
|
||||
++(1);
|
||||
--(1);
|
||||
|
||||
(1 + 2)++;
|
||||
(1 + 2)--;
|
||||
|
||||
++(1 + 2);
|
||||
--(1 + 2);
|
||||
|
||||
(x + x)++;
|
||||
(x + x)--;
|
||||
|
||||
++(x + x);
|
||||
--(x + x);
|
||||
|
||||
//OK
|
||||
x++;
|
||||
x--;
|
||||
|
||||
++x;
|
||||
--x;
|
||||
|
||||
(x)++;
|
||||
--(x);
|
||||
|
||||
((x))++;
|
||||
((x))--;
|
||||
|
||||
x[x++]++;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var x = 0;
|
||||
|
||||
// errors
|
||||
1++;
|
||||
|
||||
1++;
|
||||
1--;
|
||||
|
||||
++1;
|
||||
--1;
|
||||
|
||||
(1 + 2)++;
|
||||
(1 + 2)--;
|
||||
|
||||
++(1 + 2);
|
||||
--(1 + 2);
|
||||
|
||||
(x + x)++;
|
||||
(x + x)--;
|
||||
|
||||
++(x + x);
|
||||
--(x + x);
|
||||
|
||||
//OK
|
||||
x++;
|
||||
x--;
|
||||
|
||||
++x;
|
||||
--x;
|
||||
|
||||
x++;
|
||||
--x;
|
||||
|
||||
x++;
|
||||
x--;
|
||||
|
||||
x[x++]++;
|
||||
|
||||
`;
|
||||
|
||||
exports[`downlevelLetConst1.ts 1`] = `
|
||||
const~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
const;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
var x = 0;
|
||||
|
||||
// errors
|
||||
1 ++;
|
||||
|
||||
(1)++;
|
||||
(1)--;
|
||||
|
||||
++(1);
|
||||
--(1);
|
||||
|
||||
(1 + 2)++;
|
||||
(1 + 2)--;
|
||||
|
||||
++(1 + 2);
|
||||
--(1 + 2);
|
||||
|
||||
(x + x)++;
|
||||
(x + x)--;
|
||||
|
||||
++(x + x);
|
||||
--(x + x);
|
||||
|
||||
//OK
|
||||
x++;
|
||||
x--;
|
||||
|
||||
++x;
|
||||
--x;
|
||||
|
||||
(x)++;
|
||||
--(x);
|
||||
|
||||
((x))++;
|
||||
((x))--;
|
||||
|
||||
x[x++]++;
|
||||
Reference in new issue
Block a user