mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
allow arithmetic operations in constant expressions, handle infinity\NaN results
This commit is contained in:
@@ -8,9 +8,12 @@ tests/cases/compiler/constEnumErrors.ts(24,13): error TS4085: Index expression a
|
||||
tests/cases/compiler/constEnumErrors.ts(26,9): error TS4084: 'const' enums can only be used in property access expressions.
|
||||
tests/cases/compiler/constEnumErrors.ts(27,10): error TS4084: 'const' enums can only be used in property access expressions.
|
||||
tests/cases/compiler/constEnumErrors.ts(32,5): error TS4084: 'const' enums can only be used in property access expressions.
|
||||
tests/cases/compiler/constEnumErrors.ts(40,9): error TS4086: 'const' enum member initializer was evaluated to a non-finite number.
|
||||
tests/cases/compiler/constEnumErrors.ts(41,9): error TS4086: 'const' enum member initializer was evaluated to a non-finite number.
|
||||
tests/cases/compiler/constEnumErrors.ts(42,9): error TS4087: 'const' enum member initializer was evaluated to NaN.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constEnumErrors.ts (10 errors) ====
|
||||
==== tests/cases/compiler/constEnumErrors.ts (13 errors) ====
|
||||
const enum E {
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'E'.
|
||||
@@ -62,4 +65,21 @@ tests/cases/compiler/constEnumErrors.ts(32,5): error TS4084: 'const' enums can o
|
||||
|
||||
foo(E2);
|
||||
~~
|
||||
!!! error TS4084: 'const' enums can only be used in property access expressions.
|
||||
!!! error TS4084: 'const' enums can only be used in property access expressions.
|
||||
|
||||
const enum NaNOrInfinity {
|
||||
A = 9007199254740992,
|
||||
B = A * A,
|
||||
C = B * B,
|
||||
D = C * C,
|
||||
E = D * D,
|
||||
F = E * E, // overflow
|
||||
~~~~~
|
||||
!!! error TS4086: 'const' enum member initializer was evaluated to a non-finite number.
|
||||
G = 1 / 0, // overflow
|
||||
~~~~~
|
||||
!!! error TS4086: 'const' enum member initializer was evaluated to a non-finite number.
|
||||
H = 0 / 0 // NaN
|
||||
~~~~~
|
||||
!!! error TS4087: 'const' enum member initializer was evaluated to NaN.
|
||||
}
|
||||
@@ -30,7 +30,18 @@ var y = [E2];
|
||||
function foo(t: any): void {
|
||||
}
|
||||
|
||||
foo(E2);
|
||||
foo(E2);
|
||||
|
||||
const enum NaNOrInfinity {
|
||||
A = 9007199254740992,
|
||||
B = A * A,
|
||||
C = B * B,
|
||||
D = C * C,
|
||||
E = D * D,
|
||||
F = E * E, // overflow
|
||||
G = 1 / 0, // overflow
|
||||
H = 0 / 0 // NaN
|
||||
}
|
||||
|
||||
//// [constEnumErrors.js]
|
||||
var E;
|
||||
|
||||
@@ -29,4 +29,15 @@ var y = [E2];
|
||||
function foo(t: any): void {
|
||||
}
|
||||
|
||||
foo(E2);
|
||||
foo(E2);
|
||||
|
||||
const enum NaNOrInfinity {
|
||||
A = 9007199254740992,
|
||||
B = A * A,
|
||||
C = B * B,
|
||||
D = C * C,
|
||||
E = D * D,
|
||||
F = E * E, // overflow
|
||||
G = 1 / 0, // overflow
|
||||
H = 0 / 0 // NaN
|
||||
}
|
||||
Reference in New Issue
Block a user