Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

CallExpression not processed in correct order in complex case #244

@loganfsmyth

Description

@loganfsmyth
function *fn(){
  (yield 1)(yield 2)(yield 3);
}
var gen = fn();
console.log('a', gen.next());
console.log('b', gen.next());
console.log('c', gen.next());
console.log('d', gen.next());

will throw when executing d because all yields are processed before attempting to call the functions, whereas the expectation is that it would throw when processing c.

The output currently is

case 0:
      context$1$0.next = 2;
      return 1;
    case 2:
      context$1$0.next = 4;
      return 2;
    case 4:
      context$1$0.t0 = context$1$0.sent;
      context$1$0.next = 7;
      return 3;
    case 7:
      context$1$0.t1 = context$1$0.sent;
      (0, context$1$0.sent)(context$1$0.t0)(context$1$0.t1);

where really the first call should be in the earlier case.

Originally raised on Babel's side in http://stackoverflow.com/questions/36958171/es6-yield-yield-1yield-2yield-3 but raising here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions