summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst/src/eval/ops.rs11
-rw-r--r--tests/typ/compiler/ops-invalid.typ2
2 files changed, 12 insertions, 1 deletions
diff --git a/crates/typst/src/eval/ops.rs b/crates/typst/src/eval/ops.rs
index 4a64cfed..093eaa5f 100644
--- a/crates/typst/src/eval/ops.rs
+++ b/crates/typst/src/eval/ops.rs
@@ -52,6 +52,16 @@ pub fn pos(value: Value) -> StrResult<Value> {
Ratio(v) => Ratio(v),
Relative(v) => Relative(v),
Fraction(v) => Fraction(v),
+ Symbol(_) | Str(_) | Bytes(_) | Content(_) | Array(_) | Dict(_) | Datetime(_) => {
+ mismatch!("cannot apply unary '+' to {}", value)
+ }
+ Dyn(d) => {
+ if d.is::<Align>() {
+ mismatch!("cannot apply unary '+' to {}", d)
+ } else {
+ mismatch!("cannot apply '+' to {}", d)
+ }
+ }
v => mismatch!("cannot apply '+' to {}", v),
})
}
@@ -67,6 +77,7 @@ pub fn neg(value: Value) -> StrResult<Value> {
Relative(v) => Relative(-v),
Fraction(v) => Fraction(-v),
Duration(v) => Duration(-v),
+ Datetime(_) => mismatch!("cannot apply unary '-' to {}", value),
v => mismatch!("cannot apply '-' to {}", v),
})
}
diff --git a/tests/typ/compiler/ops-invalid.typ b/tests/typ/compiler/ops-invalid.typ
index 7e8b63ef..de8e6234 100644
--- a/tests/typ/compiler/ops-invalid.typ
+++ b/tests/typ/compiler/ops-invalid.typ
@@ -14,7 +14,7 @@
#test({2*}, 2)
---
-// Error: 3-13 cannot apply '+' to content
+// Error: 3-13 cannot apply unary '+' to content
#(+([] + []))
---