no-context / moo

Optimised tokenizer/lexer generator! 🐄 Uses /y for performance. Moo.
BSD 3-Clause "New" or "Revised" License
817 stars 65 forks source link

TypeError: Cannot read property 'groups' of undefined #108

Closed larsgw closed 5 years ago

larsgw commented 5 years ago

I'm getting the following error:

/home/larsgw/.../node_modules/moo/moo.js:311
      var groups = state.groups
                         ^

TypeError: Cannot read property 'groups' of undefined
    at Object.compileStates [as states] (/home/larsgw/.../node_modules/moo/moo.js:311:26)
    at Object.states (/home/larsgw/.../src/moo.js:13:26)
    at ...

I believe it has to do with this line redefining keys, due to hoisting. Changing that variable and references to it to for example keysFast seems to work.

https://github.com/no-context/moo/blob/8b5064009b1eff7e37f097a8d562c663c404c332/moo.js#L313-L316

tjvr commented 5 years ago

Hey, thanks for the bug report! Which version is this on?

Sent with GitHawk

larsgw commented 5 years ago

Thanks for the quick reply! I'm on the master branch, it seems to work fine on v0.4.3. However, all the docs (mostly those on keywords) are for the master branch, so I use that one at the moment. Example code:

moo.states({
  main: {
    a: 'a',
    b: 'b'
  }
})