Comment #4 on issue 705 by [email protected]: Non-enumerable property fails to shadow inherited enumerable property from for-in
http://code.google.com/p/v8/issues/detail?id=705

It looks like the problem is right about here: https://github.com/v8/v8/blob/master/src/objects.cc#L5999

On each turn through the loop over prototypes, v8 is considering only enumerable keys -- note the calls to NumberOfEnumElements() and GetEnumElementKeys().

I think it would be necessary to maintain a map of all elements, whether enumerable or not, and use an algorithm like this (pseudocode):

seenKeys = []

for each object in prototype chain:

  visibleKeys = GetEnumElementKeys()
  allKeys = GetElementKeys()

  visibleKeys = Subtract(visibleKeys, seenKeys)
  content = Union(content, visibleKeys)
  seenKeys = Union(seenKeys, allKeys)

ES5 describes its desired result, but does not specify an algorithm: http://www.ecma-international.org/ecma-262/5.1/#sec-12.6.4

ES6 (draft) describes an algorithm in terms of generators: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ordinary-object-internal-methods-and-internal-slots-enumerate

Note in ES6 the use of a Set to enforce the rule that a name is only considered once, and that higher-level nonEnumerable keys shadow lower-level enumerable keys.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to