Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Defining $ctx in a generator function breaks conversion #22

Closed
ghost opened this issue Oct 22, 2013 · 2 comments
Closed

Defining $ctx in a generator function breaks conversion #22

ghost opened this issue Oct 22, 2013 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 22, 2013

For example:

function *range(max, step) {
  var $ctx = {};
  var count = 0;
  step = step || 1;

  for (var i = 0; i < max; i += step) {
    count++;
    yield i;
  }

  return count;
}

var gen = range(20, 3), info;

while (!(info = gen.next()).done) {
  console.log(info.value);
}

console.log("steps taken: " + info.value);
@benjamn
Copy link
Contributor

benjamn commented Oct 22, 2013

Yes, for what it's worth, that's a known problem (see also #11). Definitely intend to fix it, but for now my only recommendation is not to use $ctx as a variable name.

By the way, you're the first person who's submitted a broken test case, so my hat is off to you @r04r!

@ghost
Copy link
Author

ghost commented Oct 22, 2013

Ah, glad that the problem is known already. I was just trying to break the conversion when I saw it posted on HN and noticed this so I figured I'd submit an issue. Great job on the project so far! Definitely looks promising.

nicolo-ribaudo pushed a commit to babel/regenerator-for-babel that referenced this issue Mar 26, 2025
nicolo-ribaudo pushed a commit to babel/regenerator-for-babel that referenced this issue Mar 26, 2025
nicolo-ribaudo pushed a commit to babel/regenerator-for-babel that referenced this issue Mar 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant