erg/compiler/erg_compiler/context/hint.rs
Shunsuke Shibayama fb0d2f5737 Refactor
2022-09-05 11:11:57 +09:00

24 lines
743 B
Rust

use erg_common::Str;
use erg_type::Type;
use crate::context::Context;
impl Context {
pub(crate) fn get_type_mismatch_hint(&self, expected: &Type, found: &Type) -> Option<Str> {
let expected = if let Type::FreeVar(fv) = expected {
if fv.is_linked() {
fv.crack().clone()
} else {
let (_sub, sup) = fv.get_bound_types().unwrap();
sup
}
} else {
expected.clone()
};
match (&expected.name()[..], &found.name()[..]) {
("Eq", "Float") => Some(Str::ever("Float has no equivalence relation defined. you should use `l - r <= Float.EPSILON` instead of `l == r`.")),
_ => None,
}
}
}