Skip to content

Commit

Permalink
Merge branch 'master' into 6304-sha-msg-block-size-16
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh authored Oct 24, 2024
2 parents da0f98d + 598230d commit 77c1bc9
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions tooling/nargo_fmt/src/formatter/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,15 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> {
if formatter.is_at(Token::Assign) {
formatter.write_token(Token::Assign);
} else {
while formatter.token != Token::Assign {
formatter.write_current_token();
formatter.bump();
formatter.skip_comments_and_whitespace();
}
formatter.write_token(Token::Assign);
// This is something like `x += 1`, which is parsed as an
// Assign with an InfixExpression as its right-hand side: `x = x + 1`.
// There will always be two tokens here, like `+ =` or `> >=`.
formatter.write_current_token();
formatter.bump();
formatter.skip_comments_and_whitespace();
formatter.write_current_token();
formatter.bump();

is_op_assign = true;
}
formatter.write_space();
Expand Down Expand Up @@ -435,6 +438,16 @@ mod tests {
assert_format(src, expected);
}

#[test]
fn format_shift_right_assign() {
let src = " fn foo() { x >>= 2 ; } ";
let expected = "fn foo() {
x >>= 2;
}
";
assert_format(src, expected);
}

#[test]
fn format_comptime_let_statement() {
let src = " fn foo() { comptime let x = 1 ; } ";
Expand Down

0 comments on commit 77c1bc9

Please sign in to comment.