Bug regarding EcmaScript 6 'let' declaration and template literals.
Reported by
evil.to...@gmail.com,
May 3 2017
|
||||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36
Steps to reproduce the problem:
1. Open a new tab in Chrome
2. Open the console
3. Run the following code sequence:
let test = com`Test ${something} apples`;
function com(literals, ...substitutions) { for (let i = 0; i < substitutions.length; i++) console.log(substitutions[i]); return '123'}
let something = {whatever: 3};
test = com`Test ${something} apples`;
let test = com`Test ${something} apples`;
var test = com`Test ${something} apples`;
test
typeof test
What is the expected behavior?
the 'test' variable should hold the value '123', but instead it is undefined and can't be defined. It seems to be stuck into an undefined state.
There seems to be a bug with the JavaScript interpreter in Chrome. This concerns 'let' declaration and template literals in EcmaScript 6.
What went wrong?
This will render the 'test' variable into an unknown state. It will be considered undefined but it will also throw an 'Uncaught SyntaxError: Identifier 'test' has already been declared' when trying to declare wither using let or var. Even the safe typeof operator will throw an 'Uncaught ReferenceError: test is not defined' exception.
Did this work before? N/A
Chrome version: 58.0.3029.81 Channel: stable
OS Version: 10.0
Flash Version:
,
May 3 2017
Is there a way to edit the bug report title since it's not related to template literals?
,
May 3 2017
Working as expected: let test; test = one + two; test = 123; Bug: let test = one + two; test = 123; // throws and exception
,
May 4 2017
@evil.toshz--- Could you please provide us the sample file with the code to be executed for expected and actual bug you are facing .. that would be helpful for us to triage the issue better. Thanks!
,
May 5 2017
,
May 7 2017
,
May 8 2017
This is as-specced in ES6. What you're seeing in Firefox is special behavior in their JavaScript console to allow this to work. This has long been a feature request in Chrome, so triaging as such. I suspect we already have a bug open somewhere for this that this can be duped against, but I can't find it off the top of my head, so CCing a few other folks who might have that bug handy.
,
Dec 11 2017
As per comment #7. |
||||||
►
Sign in to add a comment |
||||||
Comment 1 by evil.to...@gmail.com
, May 3 2017