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

[Bug] closure() function can cause Maximum call stack size exceeded #6

Open
matthew-dean opened this issue Aug 26, 2023 · 4 comments
Open

Comments

@matthew-dean
Copy link

I'm getting a Maximum call stack size exceeded in the closure() function. I'm attempting to investigate, and no doubt there's a problem in my grammar; but I thought it would be worth reporting that there is apparently a grammar problem that can trigger this.

@matthew-dean matthew-dean changed the title [Bug] closure() function can cause an infinite loop [Bug] closure() function can cause Maximum call stack size exceeded Aug 26, 2023
@matthew-dean
Copy link
Author

Oh okay, apparently it was this rule:

$.RULE('expression', () => {
    $.SUBRULE($.expressionValue, { LABEL: 'L' })
    $.MANY(() => {
      $.OR([
        {
          ALT: () => {
            $.OR2([
              { ALT: () => $.CONSUME(T.Plus) },
              { ALT: () => $.CONSUME(T.Minus) },
              { ALT: () => $.CONSUME(T.Star) },
              { ALT: () => $.CONSUME(T.Divide) }
            ])
            $.SUBRULE2($.expressionValue, { LABEL: 'R' })
          }
        },
        {
          GATE: $.noSep,
          ALT: () => {
            /** This will be interpreted by Less as a complete expression */
            $.CONSUME(T.Signed)
          }
        },
        // The existence of this causes an infinite loop in this package.
        { ALT: EMPTY_ALT() }
      ])
    })
  })

@msujew
Copy link
Member

msujew commented Aug 27, 2023

Have you disabled the validator for your parser? A MANY wrapping an empty element should throw an error during validation.

@matthew-dean
Copy link
Author

Nope, I had't disabled the validator.

@msujew
Copy link
Member

msujew commented Aug 28, 2023

I see. I'm on vacation until next week, but I'll look into these issues and see what I can do once I'm back.

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