summaryrefslogtreecommitdiff
path: root/src/eval/array.rs
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 /src/eval/array.rs
parente7aadbd580cb9c8d6c984d3970a4576d53028a6a (diff)
Clearer error messages for failed comparisons
Fixes #1231
Diffstat (limited to 'src/eval/array.rs')
-rw-r--r--src/eval/array.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/eval/array.rs b/src/eval/array.rs
index 6ae5d7cf..d0b63b35 100644
--- a/src/eval/array.rs
+++ b/src/eval/array.rs
@@ -344,17 +344,14 @@ impl Array {
vec.make_mut().sort_by(|a, b| {
// Until we get `try` blocks :)
match (key_of(a.clone()), key_of(b.clone())) {
- (Ok(a), Ok(b)) => a.partial_cmp(&b).unwrap_or_else(|| {
- if result.is_ok() {
- result = Err(eco_format!(
- "cannot order {} and {}",
- a.type_name(),
- b.type_name(),
- ))
- .at(span);
- }
- Ordering::Equal
- }),
+ (Ok(a), Ok(b)) => {
+ typst::eval::ops::compare(&a, &b).unwrap_or_else(|err| {
+ if result.is_ok() {
+ result = Err(err).at(span);
+ }
+ Ordering::Equal
+ })
+ }
(Err(e), _) | (_, Err(e)) => {
if result.is_ok() {
result = Err(e);