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

Error on break statement with label specified #169

Closed
lukasmlady opened this issue Jan 15, 2015 · 7 comments
Closed

Error on break statement with label specified #169

lukasmlady opened this issue Jan 15, 2015 · 7 comments

Comments

@lukasmlady
Copy link

This piece of code throws this error: AssertionError: x: invalid completion record: {"type":"break","target":null}.

function* x() {
  eventLoop:   
  while(true) {
    let {channel, value} = yield alts([stickiness, killChan]);

    switch(channel) {
      case stickiness:
        someArray.foreach(item => console.log(item));

        break;

      case killChan:
        break eventLoop;
    }
  }
};
  • If I replace let with var, then it works.
  • If I replace the arrow function with normal function, then it still fails.
  • If I remove the line with arrow function, then it works.
@benjamn
Copy link
Collaborator

benjamn commented Jan 15, 2015

Is there any way to get the error to happen without the destructuring declaration syntax? That is, without the {...}s on the left side of the let declaration?

@lukasmlady
Copy link
Author

If I replace it with let value = yield alts([stickiness, killChan]);, then the error is still there.

@benjamn
Copy link
Collaborator

benjamn commented Jan 15, 2015

Is the error thrown at runtime, or during transformation? If it's a runtime error, how are you calling x? Just trying to reproduce the problem myself.

@lukasmlady
Copy link
Author

Ok, I didn't mention this, sorry about it:

  1. The AssertionError: x: invalid completion record: {"type":"break","target":null} is thrown when I run 6to5 x.js, where regenerator 0.8.3 is used.
  2. Now, truly regenerator thing, when I run regenerator x.js, this is thrown:
Error while reading module x:
Error: StringMap expected string key
    at stringmap.has (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/stringmap/stringmap.js:81:19)
    at Scope.add (/usr/local/lib/node_modules/regenerator/node_modules/defs/build/es5/scope.js:94:21)
    at /usr/local/lib/node_modules/regenerator/node_modules/defs/build/es5/defs-main.js:124:25
    at Array.forEach (native)
    at createScopes (/usr/local/lib/node_modules/regenerator/node_modules/defs/build/es5/defs-main.js:118:27)
    at visit (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/ast-traverse/ast-traverse.js:16:19)
    at visit (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/ast-traverse/ast-traverse.js:29:25)
    at visit (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/ast-traverse/ast-traverse.js:32:21)
    at visit (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/ast-traverse/ast-traverse.js:32:21)
    at visit (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/ast-traverse/ast-traverse.js:29:25)
From previous event:
    at buildP (/usr/local/lib/node_modules/regenerator/node_modules/commoner/lib/reader.js:159:16)
    at Object.ModuleReader.processOutputP (/usr/local/lib/node_modules/regenerator/node_modules/commoner/lib/reader.js:213:16)
    at Object.ModuleReader.buildModuleP (/usr/local/lib/node_modules/regenerator/node_modules/commoner/lib/reader.js:124:23)
    at Object.wrapper [as buildModuleP] (/usr/local/lib/node_modules/regenerator/node_modules/commoner/lib/util.js:53:31)
    at /usr/local/lib/node_modules/regenerator/node_modules/commoner/lib/reader.js:118:27
Error: StringMap expected string key
    at stringmap.has (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/stringmap/stringmap.js:81:19)
    at Scope.add (/usr/local/lib/node_modules/regenerator/node_modules/defs/build/es5/scope.js:94:21)
    at /usr/local/lib/node_modules/regenerator/node_modules/defs/build/es5/defs-main.js:124:25
    at Array.forEach (native)
    at createScopes (/usr/local/lib/node_modules/regenerator/node_modules/defs/build/es5/defs-main.js:118:27)
    at visit (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/ast-traverse/ast-traverse.js:16:19)
    at visit (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/ast-traverse/ast-traverse.js:29:25)
    at visit (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/ast-traverse/ast-traverse.js:32:21)
    at visit (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/ast-traverse/ast-traverse.js:32:21)
    at visit (/usr/local/lib/node_modules/regenerator/node_modules/defs/node_modules/ast-traverse/ast-traverse.js:29:25)
From previous event:
    at buildP (/usr/local/lib/node_modules/regenerator/node_modules/commoner/lib/reader.js:159:16)
    at Object.ModuleReader.processOutputP (/usr/local/lib/node_modules/regenerator/node_modules/commoner/lib/reader.js:213:16)
    at Object.ModuleReader.buildModuleP (/usr/local/lib/node_modules/regenerator/node_modules/commoner/lib/reader.js:124:23)
    at Object.wrapper [as buildModuleP] (/usr/local/lib/node_modules/regenerator/node_modules/commoner/lib/util.js:53:31)
    at /usr/local/lib/node_modules/regenerator/node_modules/commoner/lib/reader.js:118:27

@lukasmlady
Copy link
Author

x.js contains the the code in issue description.

@lukasmlady
Copy link
Author

@benjamn looks like the destructuring is the problem - when removed, works.

@lukasmlady
Copy link
Author

Resolved in 0.8.9 from my experience.

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

2 participants