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

Clear lexing stack before parsing starts #1074

Merged
merged 1 commit into from
Dec 10, 2021
Merged

Conversation

WardBrian
Copy link
Member

@WardBrian WardBrian commented Dec 9, 2021

This fixes an issue first spotted by @spinkney in #577. The preprocessing stack is never cleared, so in particular a subsequent parse will inherit anything left on the stack. This is only possible to trigger in the Javascript compiler.

Removing the change in Preprocessor.ml makes the new test fail like so:

Syntax error in 'string', line 8, column 0 to column 5, parsing error:
Expected "generated quantities {" or end of file after end of model block.

Syntax error in 'string', line 8, column 6 to column 7, parsing error:
Expected "generated quantities {" or end of file after end of model block.

Submission Checklist

  • Run unit tests
  • Documentation
    • OR, no user-facing changes were made

Release notes

Fix an issue with parser errors 'sticking around' on subsequent runs, which primarily affected the Javascript compiler

Copyright and Licensing

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)

@WardBrian
Copy link
Member Author

WardBrian commented Dec 9, 2021

I believe this behavior can/has affected more recent versions of RStan -- see, for example, this comment. It has certainly been present in basically every version of the javascript compiler, but it's tricky to trigger unintentionally.

@spinkney
Copy link
Contributor

spinkney commented Dec 9, 2021

was this found by seantalts?

@WardBrian
Copy link
Member Author

This is my third time this week tagging the wrong GitHub username. I don’t know what’s gotten into me

Copy link
Member

@rok-cesnovar rok-cesnovar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Thanks!

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

Successfully merging this pull request may close these issues.

3 participants