You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this generator should create an infinite iterator.
Transformed code
functiontransform_generator_issue(input){varid,_loop,_ret;returnregeneratorRuntime.wrap(functiontransform_generator_issue$(_context3){while(1){switch(_context3.prev=_context3.next){case0:
id=functionid(i){returni;};_loop=/*#__PURE__*/regeneratorRuntime.mark(function_loop(){vara,f;returnregeneratorRuntime.wrap(function_loop$(_context2){while(1){switch(_context2.prev=_context2.next){case0:
a=1;f=functionf(x){returnid(x,a);};_context2.t0=input;_context2.next=5;break;case5:
_context2.next=7;return1;case7:
return_context2.abrupt("return","break");// should be _context2.abrupt("break", 8)case8:
case"end":
return_context2.stop();}}},_loop,this);});case2:
if(false){}return_context3.delegateYield(_loop(),"t0",4);case4:
_ret=_context3.t0;if(!(_ret==="break")){_context3.next=7;break;}return_context3.abrupt("break",9);case7:
_context3.next=2;break;case9:
case"end":
return_context3.stop();}}},_marked2,this);}
With the wrong _context2.abrupt("return", "break"), the iterator will jump out the while statement.
Useless effort
If i remove some code in the sample, it will produce correct code.
// every function below will give me correct code.function*transform_generator_issue(input){constid=i=>i;while(true){// const a = 1;constf=x=>id(x);switch(input){default: {yield1;break;}}}}// orfunction*transform_generator_issue(input){constid=i=>i;while(true){consta=1;// const f = x => id(x, a);switch(input){default: {yield1;break;}}}}// or a infinite loopfunction*transform_generator_issue(input){constid=i=>i;while(true){consta=1;constf=x=>id(x,a);switch(input){default: {// yield 1;break;}}}}
I can't reproduce this bug in babel cli too
I try to install @babel/cli@7.1.2 @babel/core@7.1.2 @babel/plugin-transform-regenerator@7.0.0.
run npx babel --plugins @babel/plugin-transform-regenerator code.js.
the output is:
Hey @Justin-ZS! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.
Bug Report
My generator code didn't work correctly after upgrade to babel 7
Original code
this generator should create an infinite iterator.
Transformed code
With the wrong
_context2.abrupt("return", "break")
, the iterator will jump out thewhile
statement.Useless effort
I can't reproduce this bug in offical repl
I can't reproduce this bug in babel cli too
I try to install
@babel/cli@7.1.2 @babel/core@7.1.2 @babel/plugin-transform-regenerator@7.0.0
.run
npx babel --plugins @babel/plugin-transform-regenerator code.js
.the output is:
Environment
The text was updated successfully, but these errors were encountered: