-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
Closed
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.
Description
- Version:
v11.6.0 - Platform: Linux (
linux-4.20.arch1-1-ARCH)
When attempting to declare a variable with a reserved word as an identifier name, the SyntaxError message thrown will sometimes highlight the wrong token. For example:
'use strict';
let public = 0;The above code throws the following error:
let public = 0;
^^^
SyntaxError: Unexpected strict mode reserved word
at new Script (vm.js:84:7)
at createScript (vm.js:264:10)
at Object.runInThisContext (vm.js:312:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
at executeUserCode (internal/bootstrap/node.js:342:17)
However, changing the let to a const throws this error instead:
const public = 0;
^^^^^^
SyntaxError: Unexpected strict mode reserved word
at new Script (vm.js:84:7)
at createScript (vm.js:264:10)
at Object.runInThisContext (vm.js:312:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
at executeUserCode (internal/bootstrap/node.js:342:17)
Some additional notes about when this happens, in case it helps:
- It only occurs in strict mode; non-strict-mode code gets underlined correctly
- It only occurs with
letdeclarations, notconstorvar - It does not occur with identifier names of
letorstrict, presumably because they're treated differently according to the ECMA spec - For identifiers
true,false, andnull, the bug still occurs with aletdeclaration, but the error message thrown byconstandvardeclarations becomesSyntaxError: Unexpected tokeninstead ofSyntaxError: Unexpected strict mode reserved word
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.