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 minor min-parsing issues #87

Merged
merged 2 commits into from
Aug 21, 2024
Merged

Fix minor min-parsing issues #87

merged 2 commits into from
Aug 21, 2024

Conversation

jaybosamiya-ms
Copy link
Collaborator

Hit some issues when attempting to run verusfmt on https://github.com/secure-foundations/human-eval-verus/blob/main/tasks/human_eval_001.rs ; specifically, our minimal parser would consider the parenthesis in '(' to be syntactically-relevant, rather than ignore it, thereby causing a:

thread 'main' panicked at src/rustfmt.rs:51:10:
Minimal parsing should never fail. If it did, please report this as an error.: Error { variant: ParsingError { positives: [COMMENT, tt], negatives: [] }, location: Pos(5984), line_col: Pos((155, 9)), path: None, line: "        } else if c == ')' {", continued_line: None }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This PR fixes the issues.

Automatically-minimized example that triggers the issue before this PR:

verus! {

fn a()
    ensures
{
    {
        if '(' {
            if 0 {
            }
        }
    }
}

} // verus!

While _technically_ this is not necessary, it does make it _much_ easier
to deal with `creduce`d files, which otherwise easily go and hit this
particular low-hanging issue, rather than actually interesting issues.

Fwiw, `rustfmt` automatically collapses any `macro !` to `macro!`, so we
would not be wrong in handling this specific extra amount of whitespace
during parsing.
Otherwise, the following code would parse just fine on `--verus-only`
formatting, but would fail when attempting to do the rustfmt part:

```
let x = '(' == '(';
```
@jaybosamiya-ms jaybosamiya-ms requested a review from parno August 20, 2024 21:07
@jaybosamiya-ms jaybosamiya-ms merged commit 1d3ff7b into main Aug 21, 2024
8 checks passed
@jaybosamiya-ms jaybosamiya-ms deleted the jb-min-parsing-fixes branch August 21, 2024 01:05
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.

2 participants