Skip to content

Commit 281e7a4

Browse files
author
Josh Goldberg
committed
Updated error message to mention negative values; added tests
1 parent 59f697a commit 281e7a4

File tree

8 files changed

+575
-35
lines changed

8 files changed

+575
-35
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33678,7 +33678,7 @@ namespace ts {
3367833678
}
3367933679

3368033680
if (!diagnosticMessage && numericLiteralValueImpreciselyLarge(node.text)) {
33681-
diagnosticMessage = Diagnostics.Numeric_literal_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_an_integer;
33681+
diagnosticMessage = Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_an_integer;
3368233682
}
3368333683

3368433684
if (diagnosticMessage) {

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@
10351035
"category": "Error",
10361036
"code": 1356
10371037
},
1038-
"Numeric literal values equal to 2^53 or greater are too large to be represented accurately as an integer.": {
1038+
"Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as an integer.": {
10391039
"category": "Error",
10401040
"code": 1357
10411041
},

tests/baselines/reference/constEnumErrors.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tests/cases/compiler/constEnumErrors.ts(24,13): error TS2476: A const enum membe
88
tests/cases/compiler/constEnumErrors.ts(26,9): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
99
tests/cases/compiler/constEnumErrors.ts(27,10): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
1010
tests/cases/compiler/constEnumErrors.ts(32,5): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
11-
tests/cases/compiler/constEnumErrors.ts(35,9): error TS1357: Numeric literal values equal to 2^53 or greater are too large to be represented accurately as an integer.
11+
tests/cases/compiler/constEnumErrors.ts(35,9): error TS1357: Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as an integer.
1212
tests/cases/compiler/constEnumErrors.ts(40,9): error TS2477: 'const' enum member initializer was evaluated to a non-finite value.
1313
tests/cases/compiler/constEnumErrors.ts(41,9): error TS2477: 'const' enum member initializer was evaluated to a non-finite value.
1414
tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member initializer was evaluated to disallowed value 'NaN'.
@@ -71,7 +71,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member
7171
const enum NaNOrInfinity {
7272
A = 9007199254740992,
7373
~~~~~~~~~~~~~~~~
74-
!!! error TS1357: Numeric literal values equal to 2^53 or greater are too large to be represented accurately as an integer.
74+
!!! error TS1357: Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as an integer.
7575
B = A * A,
7676
C = B * B,
7777
D = C * C,

tests/baselines/reference/impreciseNumericLiterals.errors.txt

Lines changed: 127 additions & 29 deletions
Large diffs are not rendered by default.
Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,227 @@
11
//// [impreciseNumericLiterals.ts]
22
1;
3+
-1;
34
12;
5+
-12;
46
123;
7+
-123;
58
1234;
9+
-1234;
610
12345;
11+
-12345;
712
123456;
13+
-123456;
814
1234567;
15+
-1234567;
916
12345678;
17+
-12345678;
1018
123456789;
19+
-123456789;
1120
1234567890;
21+
-1234567890;
1222
12345678901;
23+
-12345678901;
1324
123456789012;
25+
-123456789012;
1426
1234567890123;
27+
-1234567890123;
1528
12345678901234;
29+
-12345678901234;
1630
123456789012345;
31+
-123456789012345;
1732
1234567890123456;
33+
-1234567890123456;
1834
12345678901234567;
35+
-12345678901234567;
1936
123456789012345678;
37+
-123456789012345678;
2038
1234567890123456789;
39+
-1234567890123456789;
2140
12345678901234567890;
41+
-12345678901234567890;
2242

2343
9007199254740989;
44+
-9007199254740989;
2445
9007199254740990;
46+
-9007199254740990;
2547
9007199254740991;
48+
-9007199254740991;
2649
9007199254740992;
50+
-9007199254740992;
2751
9007199254740993;
52+
-9007199254740993;
2853

2954
0x1;
55+
-0x1;
3056
0x12;
57+
-0x12;
3158
0x123;
59+
-0x123;
3260
0x1234;
61+
-0x1234;
3362
0x12345;
63+
-0x12345;
3464
0x123456;
65+
-0x123456;
3566
0x1234567;
67+
-0x1234567;
3668
0x12345678;
69+
-0x12345678;
3770
0x123456789;
71+
-0x123456789;
3872
0x1234567890;
73+
-0x1234567890;
3974
0x12345678901;
75+
-0x12345678901;
4076
0x123456789012;
77+
-0x123456789012;
4178
0x1234567890123;
79+
-0x1234567890123;
4280
0x12345678901234;
81+
-0x12345678901234;
4382
0x123456789012345;
83+
-0x123456789012345;
4484
0x1234567890123456;
85+
-0x1234567890123456;
4586
0x12345678901234567;
87+
-0x12345678901234567;
4688
0x123456789012345678;
89+
-0x123456789012345678;
4790
0x1234567890123456789;
91+
-0x1234567890123456789;
4892
0x12345678901234567890;
93+
-0x12345678901234567890;
4994
0x123456789012345678901;
95+
-0x123456789012345678901;
5096
0x1234567890123456789012;
97+
-0x1234567890123456789012;
5198
0x12345678901234567890123;
99+
-0x12345678901234567890123;
52100
0x123456789012345678901234;
101+
-0x123456789012345678901234;
53102
0x1234567890123456789012345;
103+
-0x1234567890123456789012345;
54104

55105
0x19999999999998;
106+
-0x19999999999998;
56107
0x19999999999999;
108+
-0x19999999999999;
57109
0x20000000000000;
110+
-0x20000000000000;
58111
0x20000000000001;
59-
0x20000000000002;
112+
-0x20000000000001;
113+
0x20000000000002;
114+
-0x20000000000002;
115+
60116

61117
//// [impreciseNumericLiterals.js]
62118
1;
119+
-1;
63120
12;
121+
-12;
64122
123;
123+
-123;
65124
1234;
125+
-1234;
66126
12345;
127+
-12345;
67128
123456;
129+
-123456;
68130
1234567;
131+
-1234567;
69132
12345678;
133+
-12345678;
70134
123456789;
135+
-123456789;
71136
1234567890;
137+
-1234567890;
72138
12345678901;
139+
-12345678901;
73140
123456789012;
141+
-123456789012;
74142
1234567890123;
143+
-1234567890123;
75144
12345678901234;
145+
-12345678901234;
76146
123456789012345;
147+
-123456789012345;
77148
1234567890123456;
149+
-1234567890123456;
78150
12345678901234567;
151+
-12345678901234567;
79152
123456789012345678;
153+
-123456789012345678;
80154
1234567890123456789;
155+
-1234567890123456789;
81156
12345678901234567890;
157+
-12345678901234567890;
82158
9007199254740989;
159+
-9007199254740989;
83160
9007199254740990;
161+
-9007199254740990;
84162
9007199254740991;
163+
-9007199254740991;
85164
9007199254740992;
165+
-9007199254740992;
86166
9007199254740993;
167+
-9007199254740993;
87168
0x1;
169+
-0x1;
88170
0x12;
171+
-0x12;
89172
0x123;
173+
-0x123;
90174
0x1234;
175+
-0x1234;
91176
0x12345;
177+
-0x12345;
92178
0x123456;
179+
-0x123456;
93180
0x1234567;
181+
-0x1234567;
94182
0x12345678;
183+
-0x12345678;
95184
0x123456789;
185+
-0x123456789;
96186
0x1234567890;
187+
-0x1234567890;
97188
0x12345678901;
189+
-0x12345678901;
98190
0x123456789012;
191+
-0x123456789012;
99192
0x1234567890123;
193+
-0x1234567890123;
100194
0x12345678901234;
195+
-0x12345678901234;
101196
0x123456789012345;
197+
-0x123456789012345;
102198
0x1234567890123456;
199+
-0x1234567890123456;
103200
0x12345678901234567;
201+
-0x12345678901234567;
104202
0x123456789012345678;
203+
-0x123456789012345678;
105204
0x1234567890123456789;
205+
-0x1234567890123456789;
106206
0x12345678901234567890;
207+
-0x12345678901234567890;
107208
0x123456789012345678901;
209+
-0x123456789012345678901;
108210
0x1234567890123456789012;
211+
-0x1234567890123456789012;
109212
0x12345678901234567890123;
213+
-0x12345678901234567890123;
110214
0x123456789012345678901234;
215+
-0x123456789012345678901234;
111216
0x1234567890123456789012345;
217+
-0x1234567890123456789012345;
112218
0x19999999999998;
219+
-0x19999999999998;
113220
0x19999999999999;
221+
-0x19999999999999;
114222
0x20000000000000;
223+
-0x20000000000000;
115224
0x20000000000001;
225+
-0x20000000000001;
116226
0x20000000000002;
227+
-0x20000000000002;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,116 @@
11
=== tests/cases/compiler/impreciseNumericLiterals.ts ===
22
1;
3+
No type information for this code.-1;
34
No type information for this code.12;
5+
No type information for this code.-12;
46
No type information for this code.123;
7+
No type information for this code.-123;
58
No type information for this code.1234;
9+
No type information for this code.-1234;
610
No type information for this code.12345;
11+
No type information for this code.-12345;
712
No type information for this code.123456;
13+
No type information for this code.-123456;
814
No type information for this code.1234567;
15+
No type information for this code.-1234567;
916
No type information for this code.12345678;
17+
No type information for this code.-12345678;
1018
No type information for this code.123456789;
19+
No type information for this code.-123456789;
1120
No type information for this code.1234567890;
21+
No type information for this code.-1234567890;
1222
No type information for this code.12345678901;
23+
No type information for this code.-12345678901;
1324
No type information for this code.123456789012;
25+
No type information for this code.-123456789012;
1426
No type information for this code.1234567890123;
27+
No type information for this code.-1234567890123;
1528
No type information for this code.12345678901234;
29+
No type information for this code.-12345678901234;
1630
No type information for this code.123456789012345;
31+
No type information for this code.-123456789012345;
1732
No type information for this code.1234567890123456;
33+
No type information for this code.-1234567890123456;
1834
No type information for this code.12345678901234567;
35+
No type information for this code.-12345678901234567;
1936
No type information for this code.123456789012345678;
37+
No type information for this code.-123456789012345678;
2038
No type information for this code.1234567890123456789;
39+
No type information for this code.-1234567890123456789;
2140
No type information for this code.12345678901234567890;
41+
No type information for this code.-12345678901234567890;
2242
No type information for this code.
2343
No type information for this code.9007199254740989;
44+
No type information for this code.-9007199254740989;
2445
No type information for this code.9007199254740990;
46+
No type information for this code.-9007199254740990;
2547
No type information for this code.9007199254740991;
48+
No type information for this code.-9007199254740991;
2649
No type information for this code.9007199254740992;
50+
No type information for this code.-9007199254740992;
2751
No type information for this code.9007199254740993;
52+
No type information for this code.-9007199254740993;
2853
No type information for this code.
2954
No type information for this code.0x1;
55+
No type information for this code.-0x1;
3056
No type information for this code.0x12;
57+
No type information for this code.-0x12;
3158
No type information for this code.0x123;
59+
No type information for this code.-0x123;
3260
No type information for this code.0x1234;
61+
No type information for this code.-0x1234;
3362
No type information for this code.0x12345;
63+
No type information for this code.-0x12345;
3464
No type information for this code.0x123456;
65+
No type information for this code.-0x123456;
3566
No type information for this code.0x1234567;
67+
No type information for this code.-0x1234567;
3668
No type information for this code.0x12345678;
69+
No type information for this code.-0x12345678;
3770
No type information for this code.0x123456789;
71+
No type information for this code.-0x123456789;
3872
No type information for this code.0x1234567890;
73+
No type information for this code.-0x1234567890;
3974
No type information for this code.0x12345678901;
75+
No type information for this code.-0x12345678901;
4076
No type information for this code.0x123456789012;
77+
No type information for this code.-0x123456789012;
4178
No type information for this code.0x1234567890123;
79+
No type information for this code.-0x1234567890123;
4280
No type information for this code.0x12345678901234;
81+
No type information for this code.-0x12345678901234;
4382
No type information for this code.0x123456789012345;
83+
No type information for this code.-0x123456789012345;
4484
No type information for this code.0x1234567890123456;
85+
No type information for this code.-0x1234567890123456;
4586
No type information for this code.0x12345678901234567;
87+
No type information for this code.-0x12345678901234567;
4688
No type information for this code.0x123456789012345678;
89+
No type information for this code.-0x123456789012345678;
4790
No type information for this code.0x1234567890123456789;
91+
No type information for this code.-0x1234567890123456789;
4892
No type information for this code.0x12345678901234567890;
93+
No type information for this code.-0x12345678901234567890;
4994
No type information for this code.0x123456789012345678901;
95+
No type information for this code.-0x123456789012345678901;
5096
No type information for this code.0x1234567890123456789012;
97+
No type information for this code.-0x1234567890123456789012;
5198
No type information for this code.0x12345678901234567890123;
99+
No type information for this code.-0x12345678901234567890123;
52100
No type information for this code.0x123456789012345678901234;
101+
No type information for this code.-0x123456789012345678901234;
53102
No type information for this code.0x1234567890123456789012345;
103+
No type information for this code.-0x1234567890123456789012345;
54104
No type information for this code.
55105
No type information for this code.0x19999999999998;
106+
No type information for this code.-0x19999999999998;
56107
No type information for this code.0x19999999999999;
108+
No type information for this code.-0x19999999999999;
57109
No type information for this code.0x20000000000000;
110+
No type information for this code.-0x20000000000000;
58111
No type information for this code.0x20000000000001;
112+
No type information for this code.-0x20000000000001;
59113
No type information for this code.0x20000000000002;
114+
No type information for this code.-0x20000000000002;
115+
No type information for this code.
60116
No type information for this code.

0 commit comments

Comments
 (0)