mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-03 10:23:20 +00:00
fix: in
operator
* remove `In` trait, `__in__`, `__notin__` function * desugar to `__contains__` * impl Collection for Array, Set, Tuple
This commit is contained in:
parent
4f93c393c0
commit
2e9fb48f2e
19 changed files with 154 additions and 142 deletions
|
@ -12,7 +12,7 @@ use erg_common::{
|
|||
fmt_option, fmt_vec, impl_display_for_enum, impl_display_for_single_struct,
|
||||
impl_display_from_nested, impl_displayable_stream_for_wrapper, impl_from_trait_for_enum,
|
||||
impl_locational, impl_locational_for_enum, impl_nested_display_for_chunk_enum,
|
||||
impl_nested_display_for_enum, impl_stream, option_enum_unwrap,
|
||||
impl_nested_display_for_enum, impl_stream,
|
||||
};
|
||||
use erg_common::{fmt_vec_split_with, Str};
|
||||
|
||||
|
@ -1263,25 +1263,6 @@ impl Call {
|
|||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn is_assert_cast(&self) -> bool {
|
||||
self.obj
|
||||
.get_name()
|
||||
.map(|s| &s[..] == "assert")
|
||||
.unwrap_or(false)
|
||||
&& self
|
||||
.args
|
||||
.get_left_or_key("pred")
|
||||
.map(|pred| pred.is_bin_in())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn assert_cast_target_type(&self) -> Option<&Expr> {
|
||||
self.args
|
||||
.get_left_or_key("pred")
|
||||
.and_then(|pred| option_enum_unwrap!(pred, Expr::BinOp))
|
||||
.map(|bin| bin.args[1].as_ref())
|
||||
}
|
||||
|
||||
pub fn additional_operation(&self) -> Option<OperationKind> {
|
||||
self.obj.get_name().and_then(|s| match &s[..] {
|
||||
"import" => Some(OperationKind::Import),
|
||||
|
@ -4570,10 +4551,6 @@ impl Expr {
|
|||
matches!(self, Expr::Call(call) if call.is_match())
|
||||
}
|
||||
|
||||
pub fn is_bin_in(&self) -> bool {
|
||||
matches!(self, Expr::BinOp(bin) if bin.op.is(TokenKind::InOp))
|
||||
}
|
||||
|
||||
pub fn is_const_acc(&self) -> bool {
|
||||
matches!(self, Expr::Accessor(acc) if acc.is_const())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue