Issue metadata
Sign in to add a comment
|
Set constructor error messages inconsistent with for-of loops
Reported by
michael....@airbnb.com,
Feb 5 2018
|
||||||||||||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Steps to reproduce the problem: 1. run `new Set(123);` 2. run `for (const x of 123);` What is the expected behavior? It would be nice if the error message generated by passing something that is not an iterator would match the error messages generated by for-of loops in similar situations. What went wrong? Nothing here is explicitly wrong, but it looks like 2 very similar errors both of which are the result of hitting the same case in the spec (https://tc39.github.io/ecma262/#sec-getiterator step 2), result in different messages. ` The message generated by the for-of loop `Uncaught TypeError: 123 is not iterable` is much more intuitive and actionable than the message generated by the Set constructor (`Uncaught TypeError: undefined is not a function`). It looks like v8 is probably trapping errors generated by calling getIterator (https://tc39.github.io/ecma262/#sec-runtime-semantics-forin-div-ofheadevaluation-tdznames-expr-iterationkind steb 7.b) While the set constructor does not, and just lets the error bubble up without any special casing. Did this work before? No Chrome version: 64.0.3282.140 Channel: stable OS Version: OS X 10.13.3 Flash Version:
,
Feb 5 2018
It looks like firefox currently handles both cases the way that for-of whorks in v8.
,
Feb 5 2018
|
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by dtapu...@chromium.org
, Feb 5 2018