Description
openedon Nov 4, 2015
There currently is nothing in either the spec of for-in, or the spec of proxies' [[Enumerate]] method, that would ensure that all keys are converted to a string. Consequently, a for-in over a proxy could produce arbitrary key values. That may break code that assumes it can only get strings, and is particularly strange because [[Enumerate]] on ordinary objects explicitly excludes symbols to avoid this problem.
(As a secondary consequence, the sample implementation in 9.1.11 also is broken, because if proto
is a proxy, it might return equivalent keys as different values (e.g. "10"
vs 10
), such that their lookup in the visited
set fails due to the lack of canonicalisation.)
To fix this, [[Enumerate]] on proxies probably needs to create a wrapper iterator that invokes ToString on each value returned from the trap.