8000 [[FIX]] Correct error message · jshint/jshint@03b1a06 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 03b1a06

Browse files
jugglinmikerwaldron
authored andcommitted
[[FIX]] Correct error message
With the exception of `for..of` and `for..in` heads, constant binding declarations which lack an initializer are syntactically invalid. Despite this, the warning emitted for the construction suggests that the problem lies in runtime behavior. In fact, the constant is not initialized to any value because the code is never evaluated. Rephrase the warning to more accurately describe the issue.
1 parent fedaf6f commit 03b1a06

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/messages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var errors = {
2121

2222
// Constants
2323
E011: "'{a}' has already been declared.",
24-
E012: "const '{a}' is initialized to 'undefined'.",
24+
E012: "Missing initializer for constant '{a}'.",
2525
E013: "Attempting to override '{a}' which is a constant.",
2626

2727
// Regular expressions

tests/unit/core.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,8 +1170,8 @@ exports.testES6ModulesNamedExportsAffectUnused = function (test) {
11701170
];
11711171

11721172
TestRun(test)
1173-
.addError(19, 14, "const 'c1u' is initialized to 'undefined'.")
1174-
.addError(19, 19, "const 'c2u' is initialized to 'undefined'.")
1173+
.addError(19, 14, "Missing initializer for constant 'c1u'.")
1174+
.addError(19, 19, "Missing initializer for constant 'c2u'.")
11751175
.test(src1, {
11761176
esnext: true,
11771177
unused: true
@@ -2570,15 +2570,15 @@ exports.constWithoutVar = function(test) {
25702570

25712571
exports.constWithoutInit = function(test) {
25722572
TestRun(test, "single binding")
2573-
.addError(1, 6, "const 'x' is initialized to 'undefined'.")
2573+
.addError(1, 6, "Missing initializer for constant 'x'.")
25742574
.test([
25752575
"for (const x; ;) {",
25762576
" void x;",
25772577
"}"
25782578
], { esversion: 6 });
25792579

25802580
TestRun(test, "multiple bindings")
2581-
.addError(1, 6, "const 'y' is initialized to 'undefined'.")
2581+
.addError(1, 6, "Missing initializer for constant 'y'.")
25822582
.test([
25832583
"for (const y, z; ;) {",
25842584
" void (y, z);",

tests/unit/options.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,11 +2488,11 @@ exports.esnext = function (test) {
24882488
];
24892489

24902490
TestRun(test)
2491-
.addError(21, 7, "const 'immutable4' is initialized to 'undefined'.")
2491+
.addError(21, 7, "Missing initializer for constant 'immutable4'.")
24922492
.test(src, { esnext: true });
24932493

24942494
TestRun(test)
2495-
.addError(21, 7, "const 'immutable4' is initialized to 'undefined'.")
2495+
.addError(21, 7, "Missing initializer for constant 'immutable4'.")
24962496
.test(src, { moz: true });
24972497

24982498
TestRun(test)

0 commit comments

Comments
 (0)
0