Skip to content

Commit 5b3c272

Browse files
committed
Disallow left comma operator operands which don't have side effects
1 parent ab0a788 commit 5b3c272

File tree

74 files changed

+1027
-675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1027
-675
lines changed

src/compiler/checker.ts

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13209,7 +13209,16 @@ namespace ts {
1320913209
return sourceType;
1321013210
}
1321113211

13212+
/**
13213+
* This is a *shallow* check: An expression is side-effect-free if the
13214+
* evaluation of the expression *itself* cannot produce side effects.
13215+
* For example, x++ / 3 is side-effect free because the / operator
13216+
* does not have side effects.
13217+
* The intent is to "smell test" an expression for correctness in positions where
13218+
* its value is discarded (e.g. the left side of the comma operator).
13219+
*/
1321213220
function isSideEffectFree(node: Node): boolean {
13221+
node = skipParentheses(node);
1321313222
switch (node.kind) {
1321413223
case SyntaxKind.Identifier:
1321513224
case SyntaxKind.StringLiteral:
@@ -13222,8 +13231,16 @@ namespace ts {
1322213231
case SyntaxKind.UndefinedKeyword:
1322313232
case SyntaxKind.FunctionExpression:
1322413233
case SyntaxKind.ArrowFunction:
13234+
case SyntaxKind.ArrayLiteralExpression:
13235+
case SyntaxKind.ObjectLiteralExpression:
13236+
case SyntaxKind.TypeOfExpression:
13237+
case SyntaxKind.NonNullExpression:
1322513238
return true;
1322613239

13240+
case SyntaxKind.ConditionalExpression:
13241+
return isSideEffectFree((node as ConditionalExpression).whenTrue) &&
13242+
isSideEffectFree((node as ConditionalExpression).whenFalse);
13243+
1322713244
case SyntaxKind.BinaryExpression:
1322813245
if (isAssignmentOperator((node as BinaryExpression).operatorToken.kind)) {
1322913246
return false;
@@ -13233,53 +13250,21 @@ namespace ts {
1323313250

1323413251
case SyntaxKind.PrefixUnaryExpression:
1323513252
case SyntaxKind.PostfixUnaryExpression:
13253+
// Unary operators ~, !, +, and - have no side effects.
13254+
// The rest do.
1323613255
switch ((node as PrefixUnaryExpression).operator) {
1323713256
case SyntaxKind.ExclamationToken:
1323813257
case SyntaxKind.PlusToken:
1323913258
case SyntaxKind.MinusToken:
1324013259
case SyntaxKind.TildeToken:
13241-
return isSideEffectFree((node as PrefixUnaryExpression).operand);
13260+
return true;
1324213261
}
1324313262
return false;
13244-
13245-
case SyntaxKind.ParenthesizedExpression:
13246-
case SyntaxKind.TypeAssertionExpression:
13247-
case SyntaxKind.TypeOfExpression:
13248-
case SyntaxKind.AsExpression:
13249-
case SyntaxKind.NonNullExpression:
13250-
// All the nodes which just have a .expression we should check
13251-
return isSideEffectFree((node as ParenthesizedExpression).expression);
13252-
13253-
case SyntaxKind.ConditionalExpression:
13254-
return isSideEffectFree((node as ConditionalExpression).condition) &&
13255-
isSideEffectFree((node as ConditionalExpression).whenTrue) &&
13256-
isSideEffectFree((node as ConditionalExpression).whenFalse);
1325713263

13258-
case SyntaxKind.ObjectLiteralExpression:
13259-
// Note: negated forEach condition since we want to bail early to 'true',
13260-
// in other words the callback is computing "Could have side effects?"
13261-
return !forEach((node as ObjectLiteralExpression).properties, prop => {
13262-
if (isComputedPropertyName(prop.name) && !isSideEffectFree((prop.name as ComputedPropertyName).expression)) {
13263-
return true;
13264-
}
13265-
13266-
switch (prop.kind) {
13267-
case SyntaxKind.ShorthandPropertyAssignment:
13268-
case SyntaxKind.MethodDeclaration:
13269-
return false;
13270-
case SyntaxKind.PropertyAssignment:
13271-
return !isSideEffectFree((prop as PropertyAssignment).initializer);
13272-
default:
13273-
Debug.fail('Unhandled object literal property kind ' + prop.kind);
13274-
}
13275-
});
13276-
13277-
case SyntaxKind.ArrayLiteralExpression:
13278-
// See previous comment about negated callback values
13279-
return !forEach((node as ArrayLiteralExpression).elements, elem => !isSideEffectFree(elem));
13280-
13281-
case SyntaxKind.VoidExpression:
13282-
// Explicit opt-out case (listed here to avoid accidental duplication above): 'void x'
13264+
// Some forms listed here for clarity
13265+
case SyntaxKind.VoidExpression: // Explicit opt-out
13266+
case SyntaxKind.TypeAssertionExpression: // Not SEF, but can produce useful type warnings
13267+
case SyntaxKind.AsExpression: // Not SEF, but can produce useful type warnings
1328313268
default:
1328413269
return false;
1328513270
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,1): error TS2364: Invalid left-hand side of assignment expression.
2-
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,2): error TS2693: Left operand of comma operator may not be a side-effect free expression.
2+
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,2): error TS2693: Left side of comma operator is unused and has no side effects.
33

44

55
==== tests/cases/compiler/assignmentToParenthesizedExpression1.ts (2 errors) ====
@@ -8,4 +8,4 @@ tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,2): error TS2693:
88
~~~~~~
99
!!! error TS2364: Invalid left-hand side of assignment expression.
1010
~
11-
!!! error TS2693: Left operand of comma operator may not be a side-effect free expression.
11+
!!! error TS2693: Left side of comma operator is unused and has no side effects.

tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(46,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
2-
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
3-
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
1+
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
2+
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
3+
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
44

55

66
==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (3 errors) ====
7+
78
// ~ operator on any type
89

910
var ANY: any;

tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [bitwiseNotOperatorWithAnyOtherType.ts]
2+
23
// ~ operator on any type
34

45
var ANY: any;

tests/baselines/reference/bitwiseNotOperatorWithBooleanType.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [bitwiseNotOperatorWithBooleanType.ts]
2+
23
// ~ operator on boolean type
34
var BOOLEAN: boolean;
45

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,90 @@
11
=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithBooleanType.ts ===
2+
23
// ~ operator on boolean type
34
var BOOLEAN: boolean;
4-
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 3))
5+
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 3))
56

67
function foo(): boolean { return true; }
7-
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 21))
8+
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 21))
89

910
class A {
10-
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 3, 40))
11+
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 4, 40))
1112

1213
public a: boolean;
13-
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 5, 9))
14+
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 9))
1415

1516
static foo() { return false; }
16-
>foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 22))
17+
>foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 7, 22))
1718
}
1819
module M {
19-
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 8, 1))
20+
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 9, 1))
2021

2122
export var n: boolean;
22-
>n : Symbol(n, Decl(bitwiseNotOperatorWithBooleanType.ts, 10, 14))
23+
>n : Symbol(n, Decl(bitwiseNotOperatorWithBooleanType.ts, 11, 14))
2324
}
2425

2526
var objA = new A();
26-
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 13, 3))
27-
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 3, 40))
27+
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 14, 3))
28+
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 4, 40))
2829

2930
// boolean type var
3031
var ResultIsNumber1 = ~BOOLEAN;
31-
>ResultIsNumber1 : Symbol(ResultIsNumber1, Decl(bitwiseNotOperatorWithBooleanType.ts, 16, 3))
32-
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 3))
32+
>ResultIsNumber1 : Symbol(ResultIsNumber1, Decl(bitwiseNotOperatorWithBooleanType.ts, 17, 3))
33+
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 3))
3334

3435
// boolean type literal
3536
var ResultIsNumber2 = ~true;
36-
>ResultIsNumber2 : Symbol(ResultIsNumber2, Decl(bitwiseNotOperatorWithBooleanType.ts, 19, 3))
37+
>ResultIsNumber2 : Symbol(ResultIsNumber2, Decl(bitwiseNotOperatorWithBooleanType.ts, 20, 3))
3738

3839
var ResultIsNumber3 = ~{ x: true, y: false };
39-
>ResultIsNumber3 : Symbol(ResultIsNumber3, Decl(bitwiseNotOperatorWithBooleanType.ts, 20, 3))
40-
>x : Symbol(x, Decl(bitwiseNotOperatorWithBooleanType.ts, 20, 24))
41-
>y : Symbol(y, Decl(bitwiseNotOperatorWithBooleanType.ts, 20, 33))
40+
>ResultIsNumber3 : Symbol(ResultIsNumber3, Decl(bitwiseNotOperatorWithBooleanType.ts, 21, 3))
41+
>x : Symbol(x, Decl(bitwiseNotOperatorWithBooleanType.ts, 21, 24))
42+
>y : Symbol(y, Decl(bitwiseNotOperatorWithBooleanType.ts, 21, 33))
4243

4344
// boolean type expressions
4445
var ResultIsNumber4 = ~objA.a;
45-
>ResultIsNumber4 : Symbol(ResultIsNumber4, Decl(bitwiseNotOperatorWithBooleanType.ts, 23, 3))
46-
>objA.a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 5, 9))
47-
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 13, 3))
48-
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 5, 9))
46+
>ResultIsNumber4 : Symbol(ResultIsNumber4, Decl(bitwiseNotOperatorWithBooleanType.ts, 24, 3))
47+
>objA.a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 9))
48+
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 14, 3))
49+
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 9))
4950

5051
var ResultIsNumber5 = ~M.n;
51-
>ResultIsNumber5 : Symbol(ResultIsNumber5, Decl(bitwiseNotOperatorWithBooleanType.ts, 24, 3))
52-
>M.n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 10, 14))
53-
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 8, 1))
54-
>n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 10, 14))
52+
>ResultIsNumber5 : Symbol(ResultIsNumber5, Decl(bitwiseNotOperatorWithBooleanType.ts, 25, 3))
53+
>M.n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 11, 14))
54+
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 9, 1))
55+
>n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 11, 14))
5556

5657
var ResultIsNumber6 = ~foo();
57-
>ResultIsNumber6 : Symbol(ResultIsNumber6, Decl(bitwiseNotOperatorWithBooleanType.ts, 25, 3))
58-
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 21))
58+
>ResultIsNumber6 : Symbol(ResultIsNumber6, Decl(bitwiseNotOperatorWithBooleanType.ts, 26, 3))
59+
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 21))
5960

6061
var ResultIsNumber7 = ~A.foo();
61-
>ResultIsNumber7 : Symbol(ResultIsNumber7, Decl(bitwiseNotOperatorWithBooleanType.ts, 26, 3))
62-
>A.foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 22))
63-
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 3, 40))
64-
>foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 22))
62+
>ResultIsNumber7 : Symbol(ResultIsNumber7, Decl(bitwiseNotOperatorWithBooleanType.ts, 27, 3))
63+
>A.foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 7, 22))
64+
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 4, 40))
65+
>foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 7, 22))
6566

6667
// multiple ~ operators
6768
var ResultIsNumber8 = ~~BOOLEAN;
68-
>ResultIsNumber8 : Symbol(ResultIsNumber8, Decl(bitwiseNotOperatorWithBooleanType.ts, 29, 3))
69-
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 3))
69+
>ResultIsNumber8 : Symbol(ResultIsNumber8, Decl(bitwiseNotOperatorWithBooleanType.ts, 30, 3))
70+
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 3))
7071

7172
// miss assignment operators
7273
~true;
7374
~BOOLEAN;
74-
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 3))
75+
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 3))
7576

7677
~foo();
77-
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 21))
78+
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 21))
7879

7980
~true, false;
8081
~objA.a;
81-
>objA.a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 5, 9))
82-
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 13, 3))
83-
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 5, 9))
82+
>objA.a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 9))
83+
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 14, 3))
84+
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 9))
8485

8586
~M.n;
86-
>M.n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 10, 14))
87-
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 8, 1))
88-
>n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 10, 14))
87+
>M.n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 11, 14))
88+
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 9, 1))
89+
>n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 11, 14))
8990

tests/baselines/reference/bitwiseNotOperatorWithBooleanType.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithBooleanType.ts ===
2+
23
// ~ operator on boolean type
34
var BOOLEAN: boolean;
45
>BOOLEAN : boolean

tests/baselines/reference/bitwiseNotOperatorWithEnumType.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [bitwiseNotOperatorWithEnumType.ts]
2+
23
// ~ operator on enum type
34

45
enum ENUM1 { A, B, "" };
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
11
=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithEnumType.ts ===
2+
23
// ~ operator on enum type
34

45
enum ENUM1 { A, B, "" };
56
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
6-
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
7-
>B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15))
7+
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
8+
>B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 15))
89

910
// enum type var
1011
var ResultIsNumber1 = ~ENUM1;
11-
>ResultIsNumber1 : Symbol(ResultIsNumber1, Decl(bitwiseNotOperatorWithEnumType.ts, 5, 3))
12+
>ResultIsNumber1 : Symbol(ResultIsNumber1, Decl(bitwiseNotOperatorWithEnumType.ts, 6, 3))
1213
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
1314

1415
// enum type expressions
1516
var ResultIsNumber2 = ~ENUM1["A"];
16-
>ResultIsNumber2 : Symbol(ResultIsNumber2, Decl(bitwiseNotOperatorWithEnumType.ts, 8, 3))
17+
>ResultIsNumber2 : Symbol(ResultIsNumber2, Decl(bitwiseNotOperatorWithEnumType.ts, 9, 3))
1718
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
18-
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
19+
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
1920

2021
var ResultIsNumber3 = ~(ENUM1.A + ENUM1["B"]);
21-
>ResultIsNumber3 : Symbol(ResultIsNumber3, Decl(bitwiseNotOperatorWithEnumType.ts, 9, 3))
22-
>ENUM1.A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
22+
>ResultIsNumber3 : Symbol(ResultIsNumber3, Decl(bitwiseNotOperatorWithEnumType.ts, 10, 3))
23+
>ENUM1.A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
2324
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
24-
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
25+
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
2526
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
26-
>"B" : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15))
27+
>"B" : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 15))
2728

2829
// multiple ~ operators
2930
var ResultIsNumber4 = ~~~(ENUM1["A"] + ENUM1.B);
30-
>ResultIsNumber4 : Symbol(ResultIsNumber4, Decl(bitwiseNotOperatorWithEnumType.ts, 12, 3))
31+
>ResultIsNumber4 : Symbol(ResultIsNumber4, Decl(bitwiseNotOperatorWithEnumType.ts, 13, 3))
3132
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
32-
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
33-
>ENUM1.B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15))
33+
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
34+
>ENUM1.B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 15))
3435
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
35-
>B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15))
36+
>B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 15))
3637

3738
// miss assignment operators
3839
~ENUM1;
3940
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
4041

4142
~ENUM1["A"];
4243
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
43-
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
44+
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
4445

4546
~ENUM1.A, ~ENUM1["B"];
46-
>ENUM1.A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
47+
>ENUM1.A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
4748
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
48-
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
49+
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
4950
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
50-
>"B" : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15))
51+
>"B" : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 15))
5152

tests/baselines/reference/bitwiseNotOperatorWithEnumType.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithEnumType.ts ===
2+
23
// ~ operator on enum type
34

45
enum ENUM1 { A, B, "" };

0 commit comments

Comments
 (0)