diff --git a/src/eval/cast.rs b/src/eval/cast.rs index 92e4212f8..7b3066338 100644 --- a/src/eval/cast.rs +++ b/src/eval/cast.rs @@ -7,6 +7,8 @@ use ecow::EcoString; use super::{Array, Str, Value}; use crate::diag::StrResult; +use crate::eval::Type; +use crate::geom::Length; use crate::syntax::Spanned; use crate::util::separated_list; @@ -291,6 +293,14 @@ impl CastInfo { msg.push_str(", found "); msg.push_str(found.type_name()); } + if_chain::if_chain! { + if let Value::Int(i) = found; + if parts.iter().any(|p| p == Length::TYPE_NAME); + if !matching_type; + then { + msg.push_str(&format!(": a length needs a unit – did you mean {i}pt?")); + } + }; msg.into() } diff --git a/tests/typ/compiler/hint.typ b/tests/typ/compiler/hint.typ new file mode 100644 index 000000000..4fd25abb5 --- /dev/null +++ b/tests/typ/compiler/hint.typ @@ -0,0 +1,6 @@ +// Test diagnostics. +// Ref: false + +--- +// Error: 1:17-1:19 expected length, found integer: a length needs a unit – did you mean 12pt? +#set text(size: 12) \ No newline at end of file