Skip to content

Instantly share code, notes, and snippets.

@cms
Created July 29, 2010 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cms/497388 to your computer and use it in GitHub Desktop.
Save cms/497388 to your computer and use it in GitHub Desktop.
BESEN undefined accessor properties bug
// BESEN strange behavior on named accessor property
// Tested on r77
var obj = Object.defineProperty({}, 'foo', { set: undefined }),
desc = Object.getOwnPropertyDescriptor(obj, 'foo');
// Definning a setter just to make the property a named accessor property.
// (`undefined` is a valid value for the [[Set]] and [[Get]] property attributes)
// the getter is correctly `undefined`, the FromPropertyDescriptor
// and ToPropertyDescriptor abstract operations are working properly,
// (BTW, Chrome 5, 6dev and Safari 5 fail to even create the property ;)
print(desc.hasOwnProperty('get') && desc.get === undefined); // 1. true
// [[Put]]/[[CanPut]] also work propertly, an asssignment
// simply fails silently on non-strict code, [[CanPut]]
// just returns `false` (Sect. 8.12.4, Step 2.a.i)
obj.foo = 'bar';
// But [[Get]](P) should explicitly return `undefined` if the
// getter of an accessor property is `undefined` as described
// in the section 8.12.3 (on the wrongly numbered step 12):
print(obj.foo); // 2. "reference", no clue about this
print(typeof obj.foo); // 3. "undefined" as expected, but:
print(obj.foo === undefined); // 4. false
try {
obj.foo+''; // 5. "TypeError: Bad to string conversation"
} catch (e) { // I thought that print made ToString convertion
print(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment