Javascript Variables loose scope with comma defined var list inside closure

RESOLVED INVALID

Status

()

RESOLVED INVALID
7 years ago
7 years ago

People

(Reporter: keith.chadwick, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
User Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C)

Steps to reproduce:

Create a singleton implemented as 

var myClass = function(){
  var a=1,
       b=2,
       c=3;

}()


Actual results:

variables b and c are global in scope, i.e. the window object but a is protected in scope as expected.


Expected results:

variables a, b and c should be protected as they are defined within the myClass closure and initial var statement infers the scope to be within the wrapping myClass singleton.  Was able to see both b and c variables within firebug and code against them within the window object.

You will have to excuse the branch but my version of Firefox sits on the release update channel and is presently at 6.0.2
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Created attachment 561378 [details]
Testcase per comment 0; does NOT show the problem

I get a 'b is not defined' with both trunk and Firefox 6.  Can you attach a testcase actually showing the problem?
(Reporter)

Comment 2

7 years ago
My apologies but it appears to have been another issue with inherited code.  Please close the case.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.