Closed
Bug 1229998
Opened 8 years ago
Closed 8 years ago
function declaration in if statement body is not hoisted
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 585536
People
(Reporter: jon.ronnenberg, Unassigned)
References
()
Details
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0 Build ID: 20151029151421 Steps to reproduce: function FFbug() { f1(); if(true) { function f1() { console.log("f1"); } } } FFbug(); Actual results: ReferenceError: f1 is not defined Expected results: In the console there should be an entry that prints "f1" This bug impacts https://github.com/mgold/Benchmark-Visualization. Tested in FF42, FF44, Chrome and IE11. All browsers except FF are able to run the example (index.html). See issue #1 for more details: https://github.com/mgold/Benchmark-Visualization/issues/1 Note: this is not 100% exactly as the reduced example given here as this example also fails in IE and the code in Benchmark-Visualization run in IE11.
Reporter | ||
Updated•8 years ago
|
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Comment 1•8 years ago
|
||
Per spec at http://www.ecma-international.org/ecma-262/6.0/#sec-block-level-function-declarations-web-legacy-compatibility-semantics the script in comment 0 shouldn't work, as far as I can tell. The actual code in https://github.com/mgold/Benchmark-Visualization looks more like this: if (something) { legend(); function legend() { } } which should in fact work once bug 585536 is fixed. Marking duplicate based on the actual issue involved.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•