Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fixed `--verify` reporting that the output AST may be different when the input has nested parentheses such as `((x))`

## [2.6.0] - 2026-10-10

### Added
Expand Down
12 changes: 11 additions & 1 deletion src/verify_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ impl AstVerifier {

fn remove_parentheses(expression: Expression) -> Expression {
match expression {
Expression::Parentheses { expression, .. } => *expression,
// Remove every level, as the formatter can collapse `((x))` into `x`
Expression::Parentheses { expression, .. } => remove_parentheses(*expression),
_ => expression,
}
}
Expand Down Expand Up @@ -284,6 +285,15 @@ mod tests {
assert!(ast_verifier.compare(input_ast, output_ast));
}

#[test]
fn test_equivalent_removed_nested_parentheses() {
let input_ast = full_moon::parse("local x = a and ((b >= 1 and b <= 2)) and c").unwrap();
let output_ast = full_moon::parse("local x = a and (b >= 1 and b <= 2) and c").unwrap();

let mut ast_verifier = AstVerifier::new();
assert!(ast_verifier.compare(input_ast, output_ast));
}

#[test]
fn test_different_hex_numbers() {
let input_ast = full_moon::parse("local x = 0xFFAA").unwrap();
Expand Down