-
Notifications
You must be signed in to change notification settings - Fork 50
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 detection of loop headers #1247
Conversation
What is the plan for handling |
8dc1795
to
7d24daa
Compare
I had to change the |
e23322f
to
26b897a
Compare
That's not very satisfying. Why isn't this syntax allowed? What if we add a pair of parentheses ? Why didn't you use |
|
26b897a
to
277ef5f
Compare
Great! It's weird, though, that "let else" does not support this. What's happening if the pattern is irrefutable? Does rustc complain about dead code? |
adbe5a5
to
ad56307
Compare
Yes it does. Good catch. I added an attribute to disable the warning. I fixed the desugaring of variants, which was the last change to pass tests. I noticed that loop variants don't seem to do anything at the moment (unlike variants for recursive functions), there is just one not very meaningful test case for it. To handle that test case I had to merge the desugaring of variants and invariants; the result is not super pretty but it will be easier to clean this code when loop variants are actually implemented to know what it's meant to do. |
ad56307
to
0535910
Compare
0535910
to
e5eea9d
Compare
e5eea9d
to
06ce828
Compare
Fixes #164
We desugar all loops using
loop
, we put a noop marker right before theloop
keywords, and the invariants right after. We search for the loop header backwards from the invariants and stop when we hit a marker, in which case the invariants become assertions.In hindsight this should work just as well with the invariants before
loop
and the marker after it, but the implementation turns out to be slightly more convenient this way because it lets us search for the marker block by block instead of statement by statement.