facebook/regenerator

Evluation order bug inside the same expression

nicolo-ribaudo opened this issue · 0 comments

function* fn() {
  var _ref;

  (_ref = yield).method(_ref);
}

In this code, _ref = yield should be evaluated before the _ref which is passed as a parameter. The compiled code does the opposite:

  var _ref;

  return regeneratorRuntime.wrap(function fn$(_context) {
    while (1) switch (_context.prev = _context.next) {
      case 0:
        _context.next = 2;
        return;

      case 2:
        _context.t0 = _ref;

        (_ref = _context.sent).method(_context.t0);

      case 4:
      case "end":
        return _context.stop();
    }
  }, _marked);
}

https://babeljs.io/repl#?babili=false&browsers=chrome%20%3E%2022%0A&build=&builtIns=false&spec=false&loose=false&code_lz=EQVwzgpgBGAuBOBLAxrYBuAUJgZiAdqogPb4BUUO-AFAJRQDemUUAbgIbxQD68EOWZlGq9-UALxQAnoggAbACa0AdAFsIsABbEFIvjlpYAvtmSk4URLAmUahzFeX4IAD1h0sj52-pMW6rR1qVnomAEgzfDBiOQhlOWIAc2DaIRMjQyA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=true&fileSize=false&timeTravel=false&sourceType=script&lineWrap=true&presets=&prettier=false&targets=&version=7.6.0&externalPlugins=%40babel%2Fplugin-transform-regenerator%407.4.5