We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Whenever a constant is left uninitialized (and no semicolons are used) the resulting error is confusing.
Currently it will report anything specified after it as an error.
I would have expected the same error message as the browser / d8 throws.
Test Script:
$ cat test.js 'use strict' function test () { const uninitialized console.log('test') }
Node v5.11.0:
$ node test.js /srv/psichi/git/nodule/template/test.js:5 console.log('test') ^^^^^^^ SyntaxError: Unexpected identifier at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:387:25) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Function.Module.runMain (module.js:447:10) at startup (node.js:148:18) at node.js:405:3
d8 & browser: Using d8 (v5.1.0) or the chromium browser (v49.0.2623.87) the error message is much more concise
$ d8 test.js test.js:4: SyntaxError: Missing initializer in const declaration const uninitialized ^^^^^^^^^^^^^ SyntaxError: Missing initializer in const declaration
Babel: Babel throws the same kind of error, but at least provides some more context:
$ babel-node test.js /home/rhalff/.nvm/versions/node/v5.11.0/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:556 throw err; ^ SyntaxError: /srv/psichi/git/nodule/template/test.js: Unexpected token (5:2) 3 | function test () { 4 | const uninitialized > 5 | console.log('test') | ^ 6 | } 7 |
The text was updated successfully, but these errors were encountered:
I don't see how this is confusing. Until the next line, there is no error there.
It could have been
const uninitialized = 10;
So, the unexpected token is on the line after const.
const
If you put semicolons after the lines, it would tell you that a semicolon is unexpected:
const uninitialized; ^ SyntaxError: Unexpected token ;
Nevertheless, the new behaviour (as seen in v8 5.1.0) is more clear, of course.
Sorry, something went wrong.
This is done inside v8.
In Node.js 6.0 rc4, with v8 5.0, the error message is in line with what you have on d8 5.1:
const uninitialized ^^^^^^^^^^^^^ SyntaxError: Missing initializer in const declaration
Ok, thanks for the feedback.
No branches or pull requests
Whenever a constant is left uninitialized (and no semicolons are used) the resulting error is confusing.
Currently it will report anything specified after it as an error.
I would have expected the same error message as the browser / d8 throws.
Test Script:
Node v5.11.0:
d8 & browser:
Using d8 (v5.1.0) or the chromium browser (v49.0.2623.87) the error message is much more concise
Babel:
Babel throws the same kind of error, but at least provides some more context:
The text was updated successfully, but these errors were encountered: