Skip to content

Commit 2459249

Browse files
authored
Fix misplaced parentheses in Checker.isIndirectCall (#2093)
1 parent 44821b4 commit 2459249

File tree

5 files changed

+15
-41
lines changed

5 files changed

+15
-41
lines changed

internal/checker/checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12663,7 +12663,7 @@ func (c *Checker) isIndirectCall(node *ast.Node) bool {
1266312663
right := node.AsBinaryExpression().Right
1266412664
return ast.IsParenthesizedExpression(node.Parent) && ast.IsNumericLiteral(left) && left.Text() == "0" &&
1266512665
(ast.IsCallExpression(node.Parent.Parent) && node.Parent.Parent.Expression() == node.Parent ||
12666-
ast.IsTaggedTemplateExpression(node.Parent.Parent) && (ast.IsAccessExpression(right) || ast.IsIdentifier(right) && right.Text() == "eval"))
12666+
ast.IsTaggedTemplateExpression(node.Parent.Parent)) && (ast.IsAccessExpression(right) || ast.IsIdentifier(right) && right.Text() == "eval")
1266712667
}
1266812668

1266912669
func (c *Checker) checkInstanceOfExpression(left *ast.Expression, right *ast.Expression, leftType *Type, rightType *Type, checkMode CheckMode) *Type {

testdata/baselines/reference/submodule/compiler/commaOperatorLeftSideUnused.errors.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ commaOperatorLeftSideUnused.ts(38,7): error TS2695: Left side of comma operator
2121
commaOperatorLeftSideUnused.ts(39,7): error TS2695: Left side of comma operator is unused and has no side effects.
2222
commaOperatorLeftSideUnused.ts(40,7): error TS2695: Left side of comma operator is unused and has no side effects.
2323
commaOperatorLeftSideUnused.ts(41,7): error TS2695: Left side of comma operator is unused and has no side effects.
24+
commaOperatorLeftSideUnused.ts(42,7): error TS2695: Left side of comma operator is unused and has no side effects.
2425

2526

26-
==== commaOperatorLeftSideUnused.ts (23 errors) ====
27+
==== commaOperatorLeftSideUnused.ts (24 errors) ====
2728
var xx: any;
2829
var yy: any;
2930

@@ -112,6 +113,8 @@ commaOperatorLeftSideUnused.ts(41,7): error TS2695: Left side of comma operator
112113
~~~
113114
!!! error TS2695: Left side of comma operator is unused and has no side effects.
114115
xx = (0, xx)();
116+
~
117+
!!! error TS2695: Left side of comma operator is unused and has no side effects.
115118

116119
// OK cases
117120
xx = (xx ? x++ : 4, 10);

testdata/baselines/reference/submodule/compiler/commaOperatorLeftSideUnused.errors.txt.diff

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
evalAfter0.ts(4,2): error TS2695: Left side of comma operator is unused and has no side effects.
2+
3+
4+
==== evalAfter0.ts (1 errors) ====
5+
(0,eval)("10"); // fine: special case for eval
6+
7+
declare var eva;
8+
(0,eva)("10"); // error: no side effect left of comma (suspect of missing method name or something)
9+
~
10+
!!! error TS2695: Left side of comma operator is unused and has no side effects.

testdata/baselines/reference/submodule/compiler/evalAfter0.errors.txt.diff

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)