Closed Bug 861006 Opened 11 years ago Closed 2 years ago

lexically scoped interior function declarations

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: dherman, Unassigned)

References

Details

Terminology: I'll define an "interior" function declaration as one that occurs nested more deeply than the top level of its parent function or script.

SpiderMonkey is the only major JS engine that implements interior function declarations (which to date are not defined in any ES standard, except as a syntax error in ES5 strict) with dynamic scope. This is bad for both reasoning about code and performance, but also for consistency with other browsers. I created this test page:

http://dherman.github.io/substatement-functions/

which, when I tested it with various versions of Chrome, Safari, IE, and Opera, always exhibits lexical scoping semantics.

In strict mode, ES6 will have us implement function declarations with block scoping. But for web compatibility I believe in sloppy mode we have to go with hoisting to the outer function/script scope. I can live with that inconsistency.

So, I propose we attempt to make this breaking change and see if the Mozilla-specific web holds up without too much breakage. If necessary, we can stage the release of this with warnings and evangelism first. But I think we have a strong message: Mozilla is currently not behaving consistently with the rest of the web, and it's doing so in a way that causes nasty deoptimization.

Dave
Assignee: general → nobody
See Also: → 1071646
Depends on: 1071646

No longer valid. Annex B now defines how to handle this kind of function.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.