Skip to content

Commit

Permalink
Fix yield * of falsy values (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Dec 14, 2023
1 parent 7c16d9b commit 50ed6aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/runtime/runtime.js
Expand Up @@ -487,7 +487,7 @@ var runtime = (function (exports) {
};

function values(iterable) {
if (iterable || iterable === "") {
if (iterable != null) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) {
return iteratorMethod.call(iterable);
Expand Down
11 changes: 11 additions & 0 deletions test/tests.es6.js
Expand Up @@ -1537,6 +1537,17 @@ describe("delegated yield", function() {
it.next();
}, TypeError);
});

it("should work with falsy values", function () {
try {
Boolean.prototype[Symbol.iterator] = function* () { yield "Hello" };
function* gen() { yield* false; };

check(gen(), ["Hello"]);
} finally {
delete Boolean.prototype[Symbol.iterator];
}
});
});

(fullCompatibility
Expand Down

0 comments on commit 50ed6aa

Please sign in to comment.