The default bug view has changed. See this FAQ.

Javscript: Parsing of function declarations doesn't follow spec

RESOLVED INVALID

Status

()

Core
JavaScript Engine
RESOLVED INVALID
8 years ago
8 years ago

People

(Reporter: DivineGod, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2a1pre) Gecko/20081205 Minefield/3.2a1pre
Build Identifier: 

As discussed here: http://nedbatchelder.com/blog/200812/internet_explorer_mystery_1376.html

The javascript is not parsed correctly.

Example:
function really() { alert("Original"); }
if (0) {
    alert("No");
    function really() { alert("Yes, really"); }
}
really();

should alert "Yes, really" as that is the latest definition of the function, even though it inside a conditional block.

I hope this is a good explanation.

Reproducible: Always
ECMA-262 Edition does not specify functions in sub-statements, only at top level in another function or a program (see the normative grammar). Therefore this bug is invalid as summarized.

Moreover, we have extended ES3 (as allowed by its chapter 16) for ~ten years to support "function statements" whose bindings depend on control flow. So this again is invalid. There's a bug to dup against, if someone finds it feel free to change resolution accordingly.

/be
Status: UNCONFIRMED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.