prepack icon indicating copy to clipboard operation
prepack copied to clipboard

Prepack emits yield outside of generator function

Open calebmer opened this issue 5 years ago • 1 comments

Input

"use strict";

var object = {
  *["a"]() {
    yield 1;
    yield 2;
  },
};

var x = Object.keys(object);

Output

"use strict";

var x, object;
(function () {
  var _$0 = this;

  var _3 = function () {
    yield 1; // <---------------------------------- Yield outside of generator!
    yield 2;
  };

  _$0.object = {
    a: _3
  };
  _$0.x = ["a"];
}).call(this);

calebmer avatar Jul 18 '18 22:07 calebmer

I guess the fix is to retain the generator marker as appropriate when synthesizing new Babel function instances for residual functions.

NTillmann avatar Sep 22 '18 02:09 NTillmann