The relevant portion seems to be 11.13.1 Simple Assignment ( = ) The production AssignmentExpression : LeftHandSideExpression = AssignmentExpression is evaluated as follows: 1. Let lref be the result of evaluating LeftHandSideExpression. 2. Let rref be the result of evaluating AssignmentExpression. 3. Let rval be GetValue(rref). 4. Throw a SyntaxError exception if the following conditions are all true: Type(lref) is Reference is true IsStrictReference(lref) is true Type(GetBase(lref)) is Enviroment Record GetReferencedName(lref) is "eval" 5. Call PutValue(lref, rval). 6. Return rval.
which returns rval. The value returned by the setter is not used, and looking at step 7 of 8.12.5 no value is returned even if step 5 finds that a setter is defined. So for a non host object o, o.x = o.x - 1 should yield a number regardless of the details of any setter for x on o, assuming o is not frozen and said setter returns normally. 2010/5/20 Irakli Gozalishvili <[email protected]>: > Hi, > > Sorry if my question is stupid or does not really belongs here. I will be > thankful to get some clarification on es specs since I just discovered that > my interpretation of how getter / setters are supposed to behave appears to > be different from the behavior in observed in modern browsers. > > var foo = Object.create({}, { > bar: { > get: function() { > return this._foo; > }, > set: function(value) { > return this._foo = 'Hello ' + value; > } > } > }); > > var bar = foo.bar = 'setter'; > if (foo.bar !== bar) throw new Error('Unexpected'); > > The code will throw an error cause bar will be 'setter' while foo.bar will > be 'Hello setter'. I was expecting that `bar' would've get value returned > by a setter (or at least getter of foo). And this is not the case nor with > FF nor with Safari implementations. Behavior is the same if getters and > setters are used instead. Is it expected behavior ? If answer is yes, is > there any point of returning anything from setter ? > > I am also afraid that this might break some of the frameworks in rare cases > like in this example above. (a = b = c is commonly used syntax) > > Thanks a lot! > -- > Irakli Gozalishvili > Web: http://www.jeditoolkit.com/ > Phone: +31 614 205275 > Address: Taksteeg 3 - 4, 1012PB Amsterdam, Netherlands > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

