mirror of
https://github.com/typst/typst
synced 2025-05-17 02:25:27 +08:00
Improve "cannot apply '{+,-}'" error messages (#2510)
This commit is contained in:
parent
102a57056b
commit
500468fd05
@ -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),
|
||||
})
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#test({2*}, 2)
|
||||
|
||||
---
|
||||
// Error: 3-13 cannot apply '+' to content
|
||||
// Error: 3-13 cannot apply unary '+' to content
|
||||
#(+([] + []))
|
||||
|
||||
---
|
||||
|
Loading…
x
Reference in New Issue
Block a user