Bug 121201

Summary: Invalid exception trying to set property on primitive value in strict mode
Product: WebKit Reporter: Erik Arvidsson <arv>
Component: JavaScriptCoreAssignee: Oliver Hunt <oliver>
Status: NEW    
Severity: Normal CC: barraclough, ggaren
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   

Erik Arvidsson
Reported 2013-09-11 19:06:14 PDT
The following throws an exception in JSC but works correctly in V8, SpiderMonkey and Chakra: function f() { 'use strict'; 1 .foo = 'bar' } f(); Here are the relevant spec parts: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-12.2.1 MemberExpression : MemberExpression [ Expression ] 1. Let baseReference be the result of evaluating MemberExpression. 2. Let baseValue be GetValue(baseReference). ... 10. If the code matched by the syntactic production that is being evaluated is strict mode code, let strict be true, else let strict be false. 11. Return a value of type Reference whose base value is bv and whose referenced name is propertyNameString, and whose strict reference flag is strict. http://people.mozilla.org/~jorendorff/es6-draft.html#sec-6.2.4.2 PutValue (V, W) 5 is false, 6 is true, 6a is true. /base/ becomes ToObject(base) which is an object wrapper of the primitive. 6b calls [[Set]] which does not fail (the object wrapper is extensible)
Attachments
Oliver Hunt
Comment 1 2013-09-12 09:56:13 PDT
Reading the spec to determine if this is correct behaviour or not. It should be easy to fix if not.
Note You need to log in before you can comment on or make changes to this bug.