Skip to content

Commit

Permalink
fix(nargo_fmt): don't consider identifiers the same if they are equal… (
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite authored Jan 13, 2025
1 parent a9acf5a commit 18ea051
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tooling/nargo_fmt/src/formatter/use_tree_merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ impl Ord for Segment {

if let (Segment::Plain(self_string), Segment::Plain(other_string)) = (self, other) {
// Case-insensitive comparison for plain segments
self_string.to_lowercase().cmp(&other_string.to_lowercase())
let ordering = self_string.to_lowercase().cmp(&other_string.to_lowercase());
if ordering == Ordering::Equal {
self_string.cmp(other_string)
} else {
ordering
}
} else {
order_number_ordering
}
Expand Down Expand Up @@ -620,4 +625,10 @@ use std::merkle::compute_merkle_root;
let expected = "use std::{as_witness, merkle::compute_merkle_root};\n";
assert_format(src, expected);
}

#[test]
fn does_not_merge_same_identifiers_if_equal_case_insensitive() {
let src = "use bigint::{BigNum, bignum::BigNumTrait};\n";
assert_format(src, src);
}
}

0 comments on commit 18ea051

Please sign in to comment.