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

Checks for misuse of nondet and oneOf #1431

Merged
merged 12 commits into from
May 7, 2024
Merged

Checks for misuse of nondet and oneOf #1431

merged 12 commits into from
May 7, 2024

Conversation

bugarela
Copy link
Collaborator

@bugarela bugarela commented May 6, 2024

Hello :octocat:

⚠️ Big diff only due to generated grammar files. Actual diff should be reasonable.

Closes #378 (it actually fails with an "effect" error, which I think it makes more sense than a parse error, but this has been greatly discussed in the past).

It also solves the most important parts of #381, but I still have to see if there's something greater to be accomplished if we make proper effects for non-determinism.

This PR introduces some checks for how nondet and oneOf can be used. The usage is quite restrictive because we need to be able to convert this to TLA+ for model checking, and the current syntax makes it seem like you can use non determinism everywhere. Hopefully, the IDE/cli errors will help people understand that these are special keywords that can't be used everywhere. Also, since the simulator allows too much, you'd only notice something is wrong when running verify or compile to TLA+.

One of the cases in particular is when nondet definitions are top-level, which is not allowed. This was already being caught, but by the parser, and it was really hard to understand the issue by the parsing error. So I changed the parser to normally parse nondet as any other qualifier, and then properly report the error later on.

Test fixtures were updated because I'm now including the definitions themselves in the lookup table, so the tables in all fixtures were updated. We have issue #1422 to address how hard it is to read the diffs - for now: sorry!

  • Tests added for any new code
  • Documentation added for any new functionality
  • Entries added to the respective CHANGELOG.md for any new functionality
  • [-] Feature table on README.md updated for any listed functionality

@@ -66,7 +66,7 @@ listed without any additional command line arguments.
| [cosmos/ics23/ics23.qnt](./cosmos/ics23/ics23.qnt) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [cosmos/lightclient/Blockchain.qnt](./cosmos/lightclient/Blockchain.qnt) | :white_check_mark: | :white_check_mark: | N/A[^parameterized] | N/A[^nostatemachine] |
| [cosmos/lightclient/LCVerificationApi.qnt](./cosmos/lightclient/LCVerificationApi.qnt) | :white_check_mark: | :white_check_mark: | N/A[^parameterized] | N/A[^nostatemachine] |
| [cosmos/lightclient/Lightclient.qnt](./cosmos/lightclient/Lightclient.qnt) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| [cosmos/lightclient/Lightclient.qnt](./cosmos/lightclient/Lightclient.qnt) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turns out all that was stopping this from working with Apalache was a hidden nondet issue :)

@bugarela bugarela requested a review from p-offtermatt May 6, 2024 18:05
@bugarela
Copy link
Collaborator Author

bugarela commented May 6, 2024

Breaking tests are unrelated to this PR. CI is picking up the latest release for Apalache I cut this morning, so I have to updated some test's expectations. I'll do that in a separate PR.

Copy link
Member

@p-offtermatt p-offtermatt left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple of comments on clarity of errors and some spelling.

@bugarela bugarela enabled auto-merge May 7, 2024 12:42
@bugarela bugarela merged commit ae57489 into main May 7, 2024
15 checks passed
@bugarela bugarela deleted the gabriela/nondet-checks branch May 7, 2024 12:47
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.

Make sure that top-level nondet fails with a parse error
2 participants