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 extra spaces in if-expr with bool negation #24

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

tjhance
Copy link
Contributor

@tjhance tjhance commented Feb 2, 2024

Currently, verusfmt adds a space for each 'condition' node. However, the grammar is set up so that this has two condition nodes:

if !b {
}

so it ends up formatted as:

if !b  {
}

See the expansion has two 'condition' nodes:

if_expr {
                  if_str {}
                  condition {
                    bang_str {}
                    condition {
                      expr_no_struct {
                        path_expr_no_generics {
                          path_no_generics {
                            path_segment_no_generics {
                              name_ref {
                                identifier {}
                              }
                            }
                          }
                        }
                      }
                    }
                  }

The PR changes the handling of the space to be with an 'if' expression or 'while' expression, rather than having it handled with the 'condition' node.

@jaybosamiya jaybosamiya requested a review from parno February 2, 2024 07:02
Copy link
Contributor

@parno parno left a comment

Choose a reason for hiding this comment

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

Looks nice -- thanks for the fix!

@parno parno merged commit 91fd350 into verus-lang:main Feb 7, 2024
1 check passed
jaybosamiya added a commit that referenced this pull request Feb 13, 2024
Important changes:
* reduce collapsing of various multiple single-line comments
* fixed extra spaces in if-expressions with negation (#24)
* fixed precedence for quantifiers and `&&&` and `|||` (#26)
* handle macro call statements (#27)
* improved handling of non-inline single-line comments (#28)
jaybosamiya added a commit that referenced this pull request Feb 13, 2024
Important changes:
* reduce collapsing of various multiple single-line comments
* fixed extra spaces in if-expressions with negation (#24)
* fixed precedence for quantifiers and `&&&` and `|||` (#26)
* handle macro call statements (#27)
* improved handling of non-inline single-line comments (#28)
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