Issue metadata
Sign in to add a comment
|
Inconsistent behavior in javascript Uncaught SyntaxError: Identifier '*****' has already been declared
Reported by
djcavan...@gmail.com,
Mar 28 2016
|
||||||||||||||||||||||
Issue description
Chrome Version : 49.0.2623.110 (64-bit)
URLs (if applicable) :
Other browsers tested:
Add OK or FAIL, along with the version, after other browsers where you
have tested this issue:
Safari: OK
Firefox: OK
IE: OK
What steps will reproduce the problem?
(1) load the following html into browser and watch console output
<!DOCTYPE html>
<html>
<body>
<script>
//test a
var a = '';
function a(){
}
console.log('no errors yet 9');
//test b
if (true) {
var b = '';
function b () {
}
}
console.log('no errors yet 16');
</script>
</body>
</html>
What is the expected result?
Legacy javascript code should still function
Consistent behavior when overwriting a variable inside an if statement and outside.
What happens instead?
Legacy code similar to the example provided no longer functions in chrome
Error received when variable overwrites a function inside an if statement
no error received when overwriting in other contexts
Please provide any additional information below. Attach a screenshot if
possible.
,
Mar 29 2016
Tested on Windows 7 using chrome latest stable M49-49.0.2623.110 by loading the provided html file and observed the error displayed in the console as shown in the above snap shot. Tested the same on chrome M45-45.0.2442.0 and observed no error instead of that displayed result saying "no errors yet 9, no errors yet 16" as seen in the snap shot. djcavanagh@ Could you please confirm is this is the expected behavior of this issue? If yes, please let us know it will be helpful to investigate this issue further. thanks!
,
Mar 30 2016
Yes, that is the expected behavior. Thanks
,
Mar 31 2016
Thank you for providing more feedback. Adding requester "brajkumar@chromium.org" for another review and adding "Needs-Review" label for tracking. For more details visit https://sites.google.com/a/chromium.org/dev/issue-tracking/autotriage - Your friendly Sheriffbot
,
Apr 4 2016
The stricter syntax checking killed my program having this code:
function something() {
var myfunc1;
var myfunc2;
function myfunc1() {
myfunc2();
}
function myfunc2() {
//...
}
}
I used the var myfunc declarations, because JSLINT does not allow using functions defined after the function call.
Without the forward declaration, the code structure gets messy and writing functions calling each other is no longer possible.
And I really think Google should not make changes to the JS parser that kill legacy programms at all.
Thanks
,
Apr 21 2016
Bisect Information: ===================== Good build: 49.0.2613.0 Bad Build : 49.0.2615.0 Change Log URL: https://chromium.googlesource.com/chromium/src/+log/58c142c6eccd0287edcf0194391f785e45a8de92..a4231e4994a90b513122bdb9a58069d26938849f v8-autoroll: https://chromium.googlesource.com/v8/v8/+log/5041f175..aca25b0c From the above V8 log suspecting below Review URL: https://codereview.chromium.org/1561603002 mythria@ - Assigning to you, Could you please check whether this is caused with respect to your change, if not please help us in assigning it to the right owner. Thanks!
,
Apr 21 2016
https://codereview.chromium.org/1561603002 may not be the cause of this problem. It is behind a flag that is not enabled by default.
,
Apr 21 2016
Reduced test case for reproducing with d8.
function f() {
var a;
function a() { // This works
}
{
var b;
function b() { // This gives syntax error.
}
}
}
f();
,
Apr 21 2016
@admak could this be related to recent changes with legacy constants?
,
Apr 21 2016
This is due to our changes for ES2015 sloppy mode block scoping of function declarations, but it looks like we might have a bug. Investigating...
,
Apr 21 2016
To the reporter: Is this causing issues in a production website you're aware of? Or is it simply the mismatch with JSLINT behavior that you're reporting? If the latter, I'd recommend taking it up with JSLINT, as using vars to make the linter "happy" doesn't make much sense to me: function declarations are always hoisted to the top of their scope. We are following the spec here (to be exact, the second bullet of https://tc39.github.io/ecma262/#sec-block-static-semantics-early-errors). Other browsers have a mish-mash of behaviors. Firefox: doesn't throw, but does for the very similar "{var x; let x;}". In Nightly, does throw (they're now following the spec too, apparently). Edge: doesn't throw for this case or for "{var x; let x;}" WebKit (nightly): same as Edge
,
Jun 1 2016
Moving this nonessential bug to the next milestone. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jul 14 2016
This issue has been moved once and is lower than Pri-1. Removing the milestone. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jul 14 2016
Marking as WontFix since the reported behavior is per spec. |
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by djcavan...@gmail.com
, Mar 28 2016