func = => yield this // compile error
cuz coffee =>
compile to es5 =>
BUT WHY??? WHY????
solution:
if body of arrow (=>) function contains yield
operator, it must compile in classic mode:
func = (function(_this) {
return function* () {
return (yield _this);
};
})(this);
If NOT contains yield
operator, then compile to es5 mode:
func = () => return this
CUZ
From the viewpoint of the programmer, there is no physical difference between normal functions and arrow functions
var func = function () { }
var func2 = () => { }
/// HOW TO KNOW ON RUNTIME WHERE ARROW FUNCTION AND WHEHE NORMAL FUNCTION???
P.S. func.toString()
in arrow functions return different string code, But this is not significant at all, compared to the terrible restrictions that you impose on a programmer, forbidding to write yield in arrow functions
no, you submit a PR.