Skip to content

Commit 18ea051

Browse files
authored
fix(nargo_fmt): don't consider identifiers the same if they are equal… (#7043)
1 parent a9acf5a commit 18ea051

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tooling/nargo_fmt/src/formatter/use_tree_merge.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ impl Ord for Segment {
179179

180180
if let (Segment::Plain(self_string), Segment::Plain(other_string)) = (self, other) {
181181
// Case-insensitive comparison for plain segments
182-
self_string.to_lowercase().cmp(&other_string.to_lowercase())
182+
let ordering = self_string.to_lowercase().cmp(&other_string.to_lowercase());
183+
if ordering == Ordering::Equal {
184+
self_string.cmp(other_string)
185+
} else {
186+
ordering
187+
}
183188
} else {
184189
order_number_ordering
185190
}
@@ -620,4 +625,10 @@ use std::merkle::compute_merkle_root;
620625
let expected = "use std::{as_witness, merkle::compute_merkle_root};\n";
621626
assert_format(src, expected);
622627
}
628+
629+
#[test]
630+
fn does_not_merge_same_identifiers_if_equal_case_insensitive() {
631+
let src = "use bigint::{BigNum, bignum::BigNumTrait};\n";
632+
assert_format(src, src);
633+
}
623634
}

0 commit comments

Comments
 (0)