Skip to content

Commit

Permalink
Clarify TypeErrors thrown by Set and new Set
Browse files Browse the repository at this point in the history
Fixes #304.
  • Loading branch information
ljharb committed Nov 18, 2014
1 parent ed0a261 commit 5f5d280
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@
// special case support for `arguments`
return new ArrayIterator(o, 'value');
}
var it = o[$iterator$]();
var itFn = o[$iterator$];
if (!ES.IsCallable(itFn)) {
throw new TypeError('value is not an iterable');
}
var it = itFn.call(o);
if (!ES.TypeIsObject(it)) {
throw new TypeError('bad iterator');
}
Expand Down Expand Up @@ -1818,6 +1822,9 @@
// required.
var SetShim = function Set(iterable) {
var set = this;
if (!ES.TypeIsObject(set)) {
throw new TypeError('Set does not accept arguments when called as a function');
}
set = emulateES6construct(set);
if (!set._es6set) {
throw new TypeError('bad set');
Expand Down

0 comments on commit 5f5d280

Please sign in to comment.