Closed
Bug 730202
Opened 13 years ago
Closed 13 years ago
define a function in "if(){}"
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: zhengzongyi, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
Build ID: 20120215223356
Steps to reproduce:
if(true){
alert(typeof fn);
function fn(){}
}
Actual results:
alert "undefined"
Expected results:
alert function
Updated•13 years ago
|
Assignee: nobody → general
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
QA Contact: untriaged → general
"Several widely used implementations of ECMAScript are known to support the use of FunctionDeclaration as a Statement. [...] It is recommended that ECMAScript implementations either disallow this usage of FunctionDeclaration or issue a warning when such a usage is encountered."[1]
[1] http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
to clarify the following is completely valid. But function declaration is parsed before the code runs so it would not be able to check the variables.
if(true) {
var fn = function() {};
alert(typeof fn);
}
You need to log in
before you can comment on or make changes to this bug.
Description
•