Closed Bug 1170752 Opened 9 years ago Closed 9 years ago

Strict mode property uniqueness

Categories

(Core :: JavaScript Engine, defect)

38 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: kurienjoseph, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Build ID: 20150525141253

Steps to reproduce:

Run the following code. 
"use strict";
var MYCHANGES = (function() {
  "use strict";
  var self = {};
  self.valueobj = { p: true, p: false };
    self.show = function () {
        alert(self.valueobj.p);
                       
    };
return self;
}());
MYCHANGES.show();


Actual results:

The program ran normally


Expected results:

As I had the use strict clause, I am expecting an error on duplicate attribute name.
Firefox 29 correctly throws the correct syntax error message
SyntaxError: property name p appears more than once in object literal

The new releases do not throw this error
config:option value
javascript.options.strict;true

Firefox website states the following:

Fourth, strict mode requires that all properties named in an object literal be unique. Normal code may duplicate property names, with the last one determining the property's value. But since only the last one does anything, the duplication is simply a vector for bugs, if the code is modified to change the property value other than by changing the last instance. Duplicate property names are a syntax error in strict mode:

"use strict";
var o = { p: 1, p: 2 }; // !!! syntax error
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
This is introduced by bug 1041128, which intentionally removed the error.  We need to fix the documentation.
  https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Strict_mode
Added note about the change.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.