Assignment to wrapper objects in strict mode
rossberg at google.com
Wed May 28 05:00:09 PDT 2014
On 28 May 2014 13:41, André Bargull <andre.bargull at udo.edu> wrote:
>> Apparently, there has been a semantic change between ES5 and ES6
>> regarding assignment to wrapper objects in strict mode. That is,
>> 'use strict'; "".x = 0
>> would throw in ES5, but AFAICS, no longer does in ES6. Was this change
>> discussed? What is the rationale?
>> (FWIW, current implementations disagree about this: e.g., V8 and SM
>> don't throw, JSC does.)
> That assignment still throws per the current ES6 draft. Following 18.104.22.168
> PutValue to 9.1.9 [[Set]], step 4.d in [[Set]] creates a dummy data
> descriptor when no inherited property was found (that way the condition in
> step 5 will evaluate to true), and step 5.b in [[Set]] returns false if the
> receiver is not an object. At that point we're back in PutValue, and step
> 6.d in PutValue will now throw TypeError in strict mode.
But base will already have been converted to a wrapper object at
PutValue step 6.a.ii before you get to [[Set]].
More information about the es-discuss