summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-05-22 13:03:35 +0200
committerLaurenz <laurmaedje@gmail.com>2023-05-22 13:06:33 +0200
commit08870d4a4c3890b9e36c67c8972e41f6af1e0042 (patch)
tree4506b9eb4de93900ebed2e68f22308b51bba5baf /library
parente7aadbd580cb9c8d6c984d3970a4576d53028a6a (diff)
Clearer error messages for failed comparisons
Fixes #1231
Diffstat (limited to 'library')
-rw-r--r--library/src/compute/calc.rs15
1 files changed, 3 insertions, 12 deletions
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs
index bd673c54..f485f817 100644
--- a/library/src/compute/calc.rs
+++ b/library/src/compute/calc.rs
@@ -831,18 +831,9 @@ fn minmax(
};
for Spanned { v, span } in iter {
- match v.partial_cmp(&extremum) {
- Some(ordering) => {
- if ordering == goal {
- extremum = v;
- }
- }
- None => bail!(
- span,
- "cannot compare {} and {}",
- extremum.type_name(),
- v.type_name(),
- ),
+ let ordering = typst::eval::ops::compare(&v, &extremum).at(span)?;
+ if ordering == goal {
+ extremum = v;
}
}