Skip to content

Commit

Permalink
Fix: yield / await in sparse array (#628)
Browse files Browse the repository at this point in the history
Fixes issue #627.
  • Loading branch information
SuperSodaSea authored Nov 14, 2022
1 parent f14287c commit afe2ee8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/transform/src/emit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,9 @@ Ep.explodeExpression = function(path, ignoreResult) {
case "ArrayExpression":
return finish(t.arrayExpression(
path.get("elements").map(function(elemPath) {
if (elemPath.isSpreadElement()) {
if (!elemPath.node) {
return null;
} if (elemPath.isSpreadElement()) {
return t.spreadElement(
self.explodeViaTempVar(null, elemPath.get("argument"), hasLeapingChildren)
);
Expand Down
18 changes: 18 additions & 0 deletions test/tests.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -2858,4 +2858,22 @@ describe("expressions containing yield subexpressions", function() {
done: true,
});
});

it("should work when yield is in a sparse array", function() {
function *gen() {
return [0, yield "foo", , 3];
}

var g = gen();

assert.deepEqual(g.next(), {
value: "foo",
done: false,
});

assert.deepEqual(g.next(1), {
value: [0, 1, , 3],
done: true,
});
});
});

0 comments on commit afe2ee8

Please sign in to comment.