Skip to content

Commit

Permalink
Print structs in a stable order
Browse files Browse the repository at this point in the history
  • Loading branch information
hunger committed Jul 5, 2024
1 parent 5dfa8d5 commit db3fe27
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/compiler/expression_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1727,9 +1727,12 @@ pub fn pretty_print(f: &mut dyn std::fmt::Write, expression: &Expression) -> std
write!(f, "]")
}
Expression::Struct { ty: _, values } => {
let mut keys: Vec<_> = values.keys().collect();
keys.sort();
write!(f, "{{ ")?;
for (name, e) in values {
write!(f, "{}: ", name)?;
for k in keys {
let e = values.get(k).unwrap();
write!(f, "{}: ", k)?;
pretty_print(f, e)?;
write!(f, ", ")?;
}
Expand Down

0 comments on commit db3fe27

Please sign in to comment.