mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-01 21:21:10 +00:00
Update value.rs
This commit is contained in:
parent
f0ecf59af1
commit
9daad37fb6
1 changed files with 15 additions and 7 deletions
|
@ -902,10 +902,18 @@ impl ValueObj {
|
||||||
TyParam::value(arr.len()).mutate(),
|
TyParam::value(arr.len()).mutate(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Self::Dict(_dict) => todo!(),
|
Self::Dict(dict) => poly(
|
||||||
Self::Code(_) => Type::Code,
|
"Dict!",
|
||||||
Self::None => Type::NoneType,
|
vec![TyParam::Dict(
|
||||||
other => panic!("{other} object cannot be mutated"),
|
dict.iter()
|
||||||
|
.map(|(k, v)| (TyParam::value(k.clone()), TyParam::value(v.clone())))
|
||||||
|
.collect(),
|
||||||
|
)],
|
||||||
|
),
|
||||||
|
other => {
|
||||||
|
log!(err "{other} object cannot be mutated");
|
||||||
|
other.class()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Self::Illegal => Type::Failure,
|
Self::Illegal => Type::Failure,
|
||||||
}
|
}
|
||||||
|
@ -913,9 +921,9 @@ impl ValueObj {
|
||||||
|
|
||||||
pub fn try_cmp(&self, other: &Self) -> Option<Ordering> {
|
pub fn try_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(l, r) if l.is_num() && r.is_num() => f64::try_from(l)
|
(l, r) if l.is_num() && r.is_num() => {
|
||||||
.unwrap()
|
f64::try_from(l).ok()?.partial_cmp(&f64::try_from(r).ok()?)
|
||||||
.partial_cmp(&f64::try_from(r).unwrap()),
|
}
|
||||||
(Self::Inf, n) | (n, Self::NegInf) if n.is_num() => Some(Ordering::Greater),
|
(Self::Inf, n) | (n, Self::NegInf) if n.is_num() => Some(Ordering::Greater),
|
||||||
(n, Self::Inf) | (Self::NegInf, n) if n.is_num() => Some(Ordering::Less),
|
(n, Self::Inf) | (Self::NegInf, n) if n.is_num() => Some(Ordering::Less),
|
||||||
(Self::NegInf, Self::Inf) => Some(Ordering::Less),
|
(Self::NegInf, Self::Inf) => Some(Ordering::Less),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue