summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorastrale-sharp <ash4567@outlook.fr>2023-04-05 16:47:12 +0200
committerGitHub <noreply@github.com>2023-04-05 16:47:12 +0200
commit085282c138899dd5aaa06bc6ae7bd2f79d75d7e1 (patch)
treef6cc8d8e87da7bd7e0f1136491212dd3be2979e6 /src/eval
parent222c590788a30eb14a905c7593d2edaa4b91cd34 (diff)
Appends a hint if length is expected but hint provided. (#580)
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/cast.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/eval/cast.rs b/src/eval/cast.rs
index 92e4212f..7b306633 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()
}