New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 646305 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

SyntaxError upon re-declaration

Reported by christof...@gmail.com, Sep 13 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36

Steps to reproduce the problem:
1. 
Execute the following piece of JavaScript in Chrome.

while (true) {
  function inc() {}
  var inc = null;
  break;
}

What is the expected behavior?
The program is syntactically correct.

What went wrong?
Uncaught SyntaxError: Identifier 'inc' has already been declared

Did this work before? N/A 

Chrome version: 52.0.2743.116  Channel: n/a
OS Version: OS X 10.10.5
Flash Version: Shockwave Flash 22.0 r0
 
The behavior is the same in recent versions of Firefox. This seems to be a relatively new change that breaks backwards compatibility.

It would be useful to have a better error message, as in Firefox: "SyntaxError: redeclaration of let inc."
Components: -Blink Blink>JavaScript
Cc: littledan@chromium.org adamk@chromium.org
Components: -Blink>JavaScript Blink>JavaScript>Language
Status: Available (was: Unconfirmed)

Comment 4 by adamk@chromium.org, Sep 14 2016

Owner: adamk@chromium.org
Status: WontFix (was: Available)
As you've figured out, this is indeed working as intended per the ECMAScript 2015 spec.

Our error message seems reasonable to me; at least, the name of the variable is pointed out. Mentioning "let" actually seems more confusing, since there's no "let" here.
Even though this is banned by the current spec, I believe it used to work. However, we've been shipping the new semantics for some time. christofferqa , was this test extracted from any particular website that broke?

Sign in to add a comment