fix: relax side effect check

This commit is contained in:
Shunsuke Shibayama 2023-10-14 02:33:49 +09:00
parent 29e49616b9
commit 5365c87cb4
5 changed files with 68 additions and 1 deletions

View file

@ -694,6 +694,22 @@ impl Accessor {
Self::Attr(attr) => &attr.ident.raw.name,
}
}
pub fn obj(&self) -> Option<&Expr> {
match self {
Self::Attr(attr) => Some(&attr.obj),
_ => None,
}
}
pub fn root_obj(&self) -> Option<&Expr> {
match self.obj() {
Some(expr @ Expr::Accessor(Accessor::Ident(_))) => Some(expr),
Some(Expr::Accessor(acc)) => acc.root_obj(),
Some(obj) => Some(obj),
None => None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]