mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-03 05:54:33 +00:00
Update hint.rs
This commit is contained in:
parent
fb9eb0a120
commit
ee04d96487
1 changed files with 8 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
use erg_common::style::{Attribute, Color, StyledStrings, THEME};
|
use erg_common::style::{Attribute, Color, StyledStrings, THEME};
|
||||||
use erg_common::{enum_unwrap, switch_lang};
|
use erg_common::{option_enum_unwrap, switch_lang};
|
||||||
|
|
||||||
use crate::ty::typaram::TyParam;
|
use crate::ty::typaram::TyParam;
|
||||||
use crate::ty::value::ValueObj;
|
use crate::ty::value::ValueObj;
|
||||||
|
@ -56,7 +56,7 @@ impl Context {
|
||||||
found: &Type,
|
found: &Type,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
if &callee_t.qual_name()[..] == "Array" && attr == Some("__getitem__") && nth == 1 {
|
if &callee_t.qual_name()[..] == "Array" && attr == Some("__getitem__") && nth == 1 {
|
||||||
let len = &callee_t.typarams()[1];
|
let len = &callee_t.typarams().get(1).cloned()?;
|
||||||
let (_, _, preds) = found.clone().deconstruct_refinement().ok()?;
|
let (_, _, preds) = found.clone().deconstruct_refinement().ok()?;
|
||||||
if let Predicate::Equal {
|
if let Predicate::Equal {
|
||||||
lhs: _,
|
lhs: _,
|
||||||
|
@ -88,7 +88,7 @@ impl Context {
|
||||||
if fv.is_linked() {
|
if fv.is_linked() {
|
||||||
fv.crack().clone()
|
fv.crack().clone()
|
||||||
} else {
|
} else {
|
||||||
let (_sub, sup) = fv.get_subsup().unwrap();
|
let (_sub, sup) = fv.get_subsup()?;
|
||||||
sup
|
sup
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -166,10 +166,10 @@ impl Context {
|
||||||
.union_types()
|
.union_types()
|
||||||
.map(|(t1, t2)| format!("cannot {verb} {t1} {preposition} {t2}"))
|
.map(|(t1, t2)| format!("cannot {verb} {t1} {preposition} {t2}"))
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
let expected_inner = Self::readable_type(&expected.inner_ts()[0]);
|
expected.inner_ts().get(0).map(|expected_inner| {
|
||||||
Some(format!(
|
let expected_inner = Self::readable_type(expected_inner);
|
||||||
"cannot {verb} {found} {preposition} {expected_inner}"
|
format!("cannot {verb} {found} {preposition} {expected_inner}")
|
||||||
))
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ impl Context {
|
||||||
if let Type::FreeVar(fv) = lhs.as_ref() {
|
if let Type::FreeVar(fv) = lhs.as_ref() {
|
||||||
let (sub, sup) = fv.get_subsup()?;
|
let (sub, sup) = fv.get_subsup()?;
|
||||||
let (verb, preposition, sequence) = Self::get_verb_and_preposition(&sup)?;
|
let (verb, preposition, sequence) = Self::get_verb_and_preposition(&sup)?;
|
||||||
let sup = enum_unwrap!(sup.typarams().remove(0), TyParam::Type);
|
let sup = option_enum_unwrap!(sup.typarams().get(0)?.clone(), TyParam::Type)?;
|
||||||
let sup = Self::readable_type(&sup);
|
let sup = Self::readable_type(&sup);
|
||||||
let (l, r) = if sequence == Sequence::Forward {
|
let (l, r) = if sequence == Sequence::Forward {
|
||||||
(sub, sup)
|
(sub, sup)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue