Is the informative definition of [[Enumerate]] buggy?

# Raul-Sebastian Mihăilă (9 years ago)

In 9.1.11. it's specified that the iterator returned by the [[Enumerate]] method iterates over String-valued keys. But the informative definition at the end of 9.1.11. is based on whatever is returned by calling Reflect.enumerate on the prototype of the current object, assuming that there is such a prototype.

If the prototype is a proxy and it's enumerate trap returns an iterator that yields other kind of values than strings, then our original object's [[Enumerate]] method will give us non-string keys as well. And they can be any kind of values, not only symbols.

# Allen Wirfs-Brock (9 years ago)

On Aug 26, 2015, at 11:03 AM, Raul-Sebastian Mihăilă wrote:

In 9.1.11. it's specified that the iterator returned by the [[Enumerate]] method iterates over String-valued keys. But the informative definition at the end of 9.1.11. is based on whatever is returned by calling Reflect.enumerate on the prototype of the current object, assuming that there is such a prototype.

If the prototype is a proxy and it's enumerate trap returns an iterator that yields other kind of values than strings, then our original object's [[Enumerate]] method will give us non-string keys as well. And they can be any kind of values, not only symbols.

And the prototype [[Enumerate]] could return the same value multiple times, which would also be a violation of the normative requirments expressed in 9.1.11

The final if statement in the informative algorithm should probably be replaced by:

if (!visited.has(protoName) && typeof protoName === "string") {
   visited.add(protoName);
   yield protoName;
}

I opened a bug for this: ecmascript#4531