regenerator icon indicating copy to clipboard operation
regenerator copied to clipboard

Transforming shorthand and computed generators in classes creates a ReferenceError

Open aickin opened this issue 7 years ago • 4 comments

I've found that if I just use regenerator and not the babel classes transform, then the following code transforms to code that raises a ReferenceError:

const computedName = "computedFn";
class MyClass {
 *someGen() {}
 *[computedName]() {}
}

Both of those generators make functions that, when called, raise an error that says ReferenceError: _callee is not defined.

This seems very similar to the shorthand and computed property name for objects bug that I fixed in PR #267, and I'd love to help fix it, but I ran into a roadblock. I tried to write a test, but it turns out that regenerator's test suite always runs the class transform, so it's not possible to write a failing unit test in the current test framework. Can you help me figure out how best to restructure the tests to allow tests that want just the regenerator transform and no others? Thanks!

aickin avatar Apr 14 '17 20:04 aickin

This is still an issue after all this time. And it's going to get worse over time as people start dropping IE11 from their browser lists making babel-env omit transforms that are no longer needed.

dantman avatar Jul 21 '18 00:07 dantman

Exactly that is what just happened to me. I upgraded browsers list, and had a hard time to find the root cause of my problem was this. Please try to fix this soon if possible.

elmart avatar Aug 02 '18 10:08 elmart

I'll throw in and say I've also just run into this problem.

I tired popping ie 11 in my browserlist but that didn't do anything ( I can't quite gather if that was the workaround fix suggested above)

DanProudfoot avatar Aug 02 '18 15:08 DanProudfoot

@dantman I agree with your prediction that this problem will get worse with time, even though I also believe it hasn't been that big of a problem until recently. In other words, this is worth fixing, though I would ask anyone who has the time to help, since I don't know when I'll be able to take a look at this myself, and I welcome new contributors!

benjamn avatar Aug 02 '18 15:08 benjamn