-
Notifications
You must be signed in to change notification settings - Fork 32
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
Range #496
Conversation
src/main/scala/viper/gobra/frontend/info/implementation/typing/MiscTyping.scala
Outdated
Show resolved
Hide resolved
src/main/scala/viper/gobra/frontend/info/implementation/typing/StmtTyping.scala
Outdated
Show resolved
Hide resolved
src/main/scala/viper/gobra/frontend/info/implementation/typing/StmtTyping.scala
Outdated
Show resolved
Hide resolved
src/main/scala/viper/gobra/frontend/info/implementation/typing/StmtTyping.scala
Outdated
Show resolved
Hide resolved
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.
Apart for the small comments we discussed in person, LGTM! I am in favor of merging it but I would like the opinion of @Felalolf or @ArquintL before doing so - in particular, I wonder whether we should just require the user to write the invariants by hand at all the times instead of trying to generate the obvious ones. The disadvantage of doing so is that (1) we have more code, (2) it might make error messages a bit obscure as shown in test case src/test/resources/regressions/features/loops/range-fail2.gobra
src/test/resources/regressions/features/loops/range-fail2.gobra
Outdated
Show resolved
Hide resolved
src/main/scala/viper/gobra/translator/encodings/combinators/TypeEncoding.scala
Show resolved
Hide resolved
I do not like that the transformation is handled by the desugarer, but since it is urgent, we can go with this solution until we might change it. |
This PR adds range for slices and arrays.
Slices and arrays have the same behavior regarding range. The general transformation to support that is the following:
Given a simple range loop in gobra:
It is transformed into:
The extra invariants are added after the user provided invariants as the second one refers to the expression in range and the user has to have provided an invariant granting access to that before.
In the case where we have a normal assignment
for i, j = range x
and not a short one, the transformation is the same, minus the variable declarations. In this case i and j could be any lvalues.