[Webkit-unassigned] [Bug 92817] use strict, string property assignment throws TypeError

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 1 13:53:06 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=92817


Oliver Hunt <oliver at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID




--- Comment #3 from Oliver Hunt <oliver at apple.com>  2012-08-01 13:53:07 PST ---
This is correct behaviour.

The evaluation of  "value.something = true" is evaluated with by getting the reference for the left hand side, then evaluating the right hand side, then calling put value.

step 1) get the reference for assignment:

11.2.1 Property Accessors
1. essentially baseReference = &value
2. baseValue = value
3. propertyNameReference = &"something" // all lookup is perform as if a.b were a["b"]
4. propertyNameValue = "something"
5. /* do nothing */
6. propertyNameString = ToString(propertyNameValue) /*"something"*/
7. strict = true /*we're in strict mode code*/
8. return Reference({base: baseValue /*string*/, 
                                name: propertyNameString /*"something"*/, 
                                strict: strict /*true*/})

we'll call the result of this lhsRef.

step 2)
Evalute the right hand side (which i won't go through as it's not relevant)

step 3) perform the assignment

PutValue(lhsRef, lhsSide /*true*/)

8.7.2 PutValue (V /*{base: string, name: "something", strict: true}*/, W/*rhs side, so the value: true*/)
1. V is a reference so do nothing
2. base=GetBase(V) /*string*/
3. /* do nothing as we've got a reference */
4. V is a property reference so we now do:
     a. base is a primitive type (string) so put = a special internal version of [[Put]] also defined in 8.7.2 
     b. put(base, V.name, W, V.strict)

    Internal [[Put]](base /* our string*/, P /*"something"*/, W/*true*/, Throw/*true -- because we're in strict mode*/)
    1. O=ToObject(base) // yay allocate a String object
    2. /* do nothing as there's no readonly "something" property in prototype chain */
    3. ownDesc = GetOwnProperty(O, P) // "something" doesn't existing on the String object so this is null
    4. /* do nothing as ownDesc is null*/
    5. desc = GetProperty(O, P) // also null as "something" isn't a property that exists anywhere on the protochain
    6. /* do nothing as desc is null so isn't an accessor property */
    7. We are trying to assign a property to a temporary object
        a. Throw is true, so we throw a TypeError.


So this is the correct behaviour, and the long (even though it's abbreviated) and winding path to throwing an exception here in strict mode.

You should file bugs on the other browsers for not doing this correctly. :D

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list