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

fix: calc of multiset crashes #2079

Merged
merged 6 commits into from
May 2, 2022
Merged

fix: calc of multiset crashes #2079

merged 6 commits into from
May 2, 2022

Conversation

MikaelMayer
Copy link
Member

Fixes #2078

calc{multiset} triggers a while loop that will try to get all inner statements, but the while loop is guarded by something that checks if the next element is the start of an expression, which it is (multiset can be the start of an expression). However, since it is not a valid expression, it will emit an error, store a dummy expression, and continue without changing the scanner's position.

The problem does not arise with iset because that keyword can be used both for set display and set comprehension, so the scanner can continue in any case.

Since there is no multiset comprehension for now, I removed the lookahead code so that now multiset always expects a ( or a { after it, and the scanner can move on in any case.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@MikaelMayer MikaelMayer added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: parser First phase of Dafny's pipeline labels Apr 29, 2022
@MikaelMayer MikaelMayer self-assigned this Apr 29, 2022
RELEASE_NOTES.md Outdated
@@ -22,6 +22,7 @@
- fix: Prevent refinements from changing datatype and newtype definitions (https://github.com/dafny-lang/dafny/pull/2038)
- feat: The new `older` modifier on arguments to predicates indicates that a predicate ensures the allocatedness of some of its arguments. This allows more functions to show that their quantifiers do not depend on the allocation state. For more information, see the reference manual section on `older`. (https://github.com/dafny-lang/dafny/pull/1936)
- fix: Fix `(!new)` checks (https://github.com/dafny-lang/dafny/issues/1419)
- fix: multiset keyword no more crashes the parser (https://github.com/dafny-lang/dafny/pull/2079)
Copy link
Member

@keyboardDrummer keyboardDrummer May 2, 2022

Choose a reason for hiding this comment

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

nitpick: multiset keyword no longer crashes the parser

@@ -386,7 +386,8 @@ bool IsSetDisplay() {
if (la.kind == _lbrace) return true;
int k = scanner.Peek().kind;
if (la.kind == _iset && k == _lbrace) return true;
if (la.kind == _multiset && (k == _lbrace || k == _openparen)) return true;
// Until there is a multiset comprehension, there is no point in checking the next item.
Copy link
Member

Choose a reason for hiding this comment

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

I would remove the // and the /* comment. I don't think a future implementor of multiset comprehensions needs these.

keyboardDrummer
keyboardDrummer previously approved these changes May 2, 2022
RELEASE_NOTES.md Outdated Show resolved Hide resolved
Source/Dafny/Dafny.atg Outdated Show resolved Hide resolved
Source/Dafny/Dafny.atg Show resolved Hide resolved
@MikaelMayer MikaelMayer enabled auto-merge (squash) May 2, 2022 16:05
@MikaelMayer MikaelMayer merged commit b9564b3 into master May 2, 2022
@MikaelMayer MikaelMayer deleted the fix-2078-multiset branch May 2, 2022 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: parser First phase of Dafny's pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Language server not robust enough and multiset keyword crash
3 participants