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

Invalid completion record on BreakStatement with label #162

Closed
sebmck opened this issue Jan 4, 2015 · 10 comments
Closed

Invalid completion record on BreakStatement with label #162

sebmck opened this issue Jan 4, 2015 · 10 comments
Labels

Comments

@sebmck
Copy link
Contributor

sebmck commented Jan 4, 2015

invalid completion record: {"type":"break","target":null}

var i = 0;
var s = '';

function* f() {
  s += 'a';
  while(i++ < 3) {
    s += 'b';
    label1: {
      s += 'c';
      break label1;
      s += 'd';
    }
    s += 'e';
  }
  s += 'f';
}

var g = f();
g.next();
assert.equal(s, 'abcebcebcef');
@sebmck
Copy link
Contributor Author

sebmck commented Jan 4, 2015

Looks like it's due to the leap manager trying to resolve it to a loop when any expression can be in a label statement.

@benjamn
Copy link
Collaborator

benjamn commented Jan 4, 2015

What's the expected behavior? Can a labeled break statement break from a labeled statement that isn't a loop?

@sebmck
Copy link
Contributor Author

sebmck commented Jan 4, 2015

Looks like it just breaks the current block. So in the original example code s += 'd'; after break label1; never gets ran.

For some context the example is taken from the traceur test suite.

@benjamn benjamn added the bug label Jan 4, 2015
@benjamn
Copy link
Collaborator

benjamn commented Jan 4, 2015

Interesting!

@benjamn benjamn closed this as completed in a7b0307 Jan 4, 2015
@sebmck
Copy link
Contributor Author

sebmck commented Jan 5, 2015

@benjamn Great! Unrelated question but have the generator error messages been standardised? I'm running 6to5 against the Traceur tests (which is how I found this bug) and the error messages don't match up which isn't that big of a deal but just thought I'd ask.

@benjamn
Copy link
Collaborator

benjamn commented Jan 5, 2015

Most if not all errors in the generator spec just say "if X then throw a TypeError" with no specified message. I've tried to keep compatibility with V8 just so the tests work in Node v0.11, but maybe I'm over-testing those error messages…

@lukasmlady
Copy link

Another invalid completion record: {"type":"break","target":null}:

  go(function*() {
    // Enter mini event loop.
    eventLoop:
    while(true) {
      let {channel, value} = yield alts([stickiness, killChan]);

      switch(channel) {
        // When the stickiness changes.
        case stickiness:
          $navItems
            .find(".js-siteNavItemIcon")
            .each((idx, el) => resetIcon($(el), state.isSticky));

          break;

        case killChan:
          break eventLoop;
      }
    }
  });

If I remove the .each((idx, el) => resetIcon($(el), state.isSticky)); line, it works - so the problem is the arrow function.

If I replace the let {channel, value} = yield alts([stickiness, killChan]); with var in the beginning, then it works as well (even with the arrow function).

@benjamn
Copy link
Collaborator

benjamn commented Jan 15, 2015

@lukasmlady would you mind minimizing that example as far as possible (if it isn't already minimal) and opening a new issue? I think this bug might have a distinct root cause.

@lukasmlady
Copy link

@benjamn yep, will do.

@lukasmlady
Copy link

@benjamn Created #169.

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

No branches or pull requests

3 participants