Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A generator's bug #2974

Closed
akira-cn opened this issue Jan 16, 2017 · 2 comments
Closed

A generator's bug #2974

akira-cn opened this issue Jan 16, 2017 · 2 comments

Comments

@akira-cn
Copy link
Contributor

akira-cn commented Jan 16, 2017

Screenshot: https://p4.ssl.qhimg.com/t01877ae91647926e9d.png

function * createStuff(num){
  let ret = [];
  for(let i = 0; i < num; i++){
    ret[i] = i + 1;
  }
  
  for(let i = num - 1; i >= 0; i--){
    let rand = Math.floor(Math.random() * i);
    yield ret[rand];
    [ret[rand], ret[i]] = [ret[i], ret[rand]];
  }
}

var result = createStuff(61);
@remy
Copy link
Member

remy commented Mar 25, 2017

Sorry, but you've not described an issue here.

@remy remy closed this as completed Mar 25, 2017
@ChelesteWang
Copy link

It looks like a good problem ,View Console Message

Exiting potential infinite loop at line 3. To disable loop protection: add "// noprotect" to your code

add // noprotect can solve this problem


in runner.js
```js
/**
   * Update the loop protoction hit function to send an event up to the parent
   * window so we can insert it in our error UI
   */
  loopProtect.hit = function (line) {
    console.warn('Exiting potential infinite loop at line ' + line + '. To disable loop protection: add "// noprotect" to your code');
    runner.postMessage('loopProtectHit', line);
  }

So , this may not be a bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants