Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Throw TypeError if proxy [[OwnPropertyKeys]] returns duplicate entries #833

Merged
merged 1 commit into from
Aug 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,9 @@ <h2>[[OwnPropertyKeys]] ( )</h2>
<li>
The return value must be a List.
</li>
<li>
The returned list must not contain any duplicate entries.
</li>
<li>
The Type of each element of the returned List is either String or Symbol.
</li>
Expand Down Expand Up @@ -8976,9 +8979,11 @@ <h1>[[OwnPropertyKeys]] ( )</h1>
1. Return ? _target_.[[OwnPropertyKeys]]().
1. Let _trapResultArray_ be ? Call(_trap_, _handler_, &laquo; _target_ &raquo;).
1. Let _trapResult_ be ? CreateListFromArrayLike(_trapResultArray_, &laquo; String, Symbol &raquo;).
1. If _trapResult_ contains any duplicate entries, throw a *TypeError* exception.
1. Let _extensibleTarget_ be ? IsExtensible(_target_).
1. Let _targetKeys_ be ? _target_.[[OwnPropertyKeys]]().
1. Assert: _targetKeys_ is a List containing only String and Symbol values.
1. Assert: _targetKeys_ contains no duplicate entries.
1. Let _targetConfigurableKeys_ be a new empty List.
1. Let _targetNonconfigurableKeys_ be a new empty List.
1. Repeat, for each element _key_ of _targetKeys_,
Expand All @@ -8992,11 +8997,11 @@ <h1>[[OwnPropertyKeys]] ( )</h1>
1. Let _uncheckedResultKeys_ be a new List which is a copy of _trapResult_.
1. Repeat, for each _key_ that is an element of _targetNonconfigurableKeys_,
1. If _key_ is not an element of _uncheckedResultKeys_, throw a *TypeError* exception.
1. Remove all occurrences of _key_ from _uncheckedResultKeys_.
1. Remove _key_ from _uncheckedResultKeys_.
1. If _extensibleTarget_ is *true*, return _trapResult_.
1. Repeat, for each _key_ that is an element of _targetConfigurableKeys_,
1. If _key_ is not an element of _uncheckedResultKeys_, throw a *TypeError* exception.
1. Remove all occurrences of _key_ from _uncheckedResultKeys_.
1. Remove _key_ from _uncheckedResultKeys_.
1. If _uncheckedResultKeys_ is not empty, throw a *TypeError* exception.
1. Return _trapResult_.
</emu-alg>
Expand All @@ -9006,6 +9011,9 @@ <h1>[[OwnPropertyKeys]] ( )</h1>
<li>
The result of [[OwnPropertyKeys]] is a List.
</li>
<li>
The returned List contains no duplicate entries.
</li>
<li>
The Type of each result List element is either String or Symbol.
</li>
Expand Down Expand Up @@ -16564,7 +16572,7 @@ <h1>EnumerateObjectProperties ( _O_ )</h1>
for (const key of Reflect.ownKeys(obj)) {
if (typeof key === "symbol") continue;
const desc = Reflect.getOwnPropertyDescriptor(obj, key);
if (desc && !visited.has(key)) {
if (desc) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this polyfill code might need more tweaking - does it still need visited at all?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to track when the same property key is also present in the prototype chain.

visited.add(key);
if (desc.enumerable) yield key;
}
Expand Down