-
Notifications
You must be signed in to change notification settings - Fork 262
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
Conversation
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) |
There was a problem hiding this comment.
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
Source/Dafny/Dafny.atg
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
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.