New issue
Advanced search Search tips

Issue 790789 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue v8:6522
Owner: ----
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

Set constructor error message when not passed an iterable is confusing

Project Member Reported by shans@chromium.org, Nov 30 2017

Issue description

Chrome Version: (copy from chrome://version)
OS: (e.g. Win7, OSX 10.9.5, etc...)

What steps will reproduce the problem?
(1) try executing for (var x of 1) { }
(2) now try executing new Set(1,2,3)

What is the expected result?

Two reasonable error messages (e.g. "Uncaught TypeError: 1 is not iterable")

What happens instead?
The for loop produces a reasonable error message, but the Set constructor says:
"Uncaught TypeError: undefined is not a function"

This is reasonably important because it's easy to accidentally omit the list square-brackets when constructing sets (e.g. writing new Set(1,2,3) instead of new Set([1,2,3])) - we should make it super easy to catch and fix this mistake.
 
Cc: yangguo@chromium.org
Components: -Blink>JavaScript Blink>JavaScript>Language
Labels: -Type-Bug Type-Feature
Status: Available (was: Untriaged)

Comment 2 by adamk@chromium.org, Dec 11 2017

Cc: gsat...@chromium.org
Mergedinto: v8:6522
Status: Duplicate (was: Available)

Sign in to add a comment