Update hir.rs

This commit is contained in:
Shunsuke Shibayama 2022-12-11 20:01:28 +09:00
parent bb03ca6097
commit 457e4bac76

View file

@ -1425,7 +1425,9 @@ pub struct Block(Vec<Expr>);
impl HasType for Block { impl HasType for Block {
#[inline] #[inline]
fn ref_t(&self) -> &Type { fn ref_t(&self) -> &Type {
self.last().unwrap().ref_t() self.last()
.map(|last| last.ref_t())
.unwrap_or(Type::FAILURE)
} }
#[inline] #[inline]
fn ref_mut_t(&mut self) -> &mut Type { fn ref_mut_t(&mut self) -> &mut Type {
@ -1433,11 +1435,11 @@ impl HasType for Block {
} }
#[inline] #[inline]
fn t(&self) -> Type { fn t(&self) -> Type {
self.last().unwrap().t() self.last().map(|last| last.t()).unwrap_or(Type::Failure)
} }
#[inline] #[inline]
fn signature_t(&self) -> Option<&Type> { fn signature_t(&self) -> Option<&Type> {
self.last().unwrap().signature_t() self.last().and_then(|last| last.signature_t())
} }
#[inline] #[inline]
fn signature_mut_t(&mut self) -> Option<&mut Type> { fn signature_mut_t(&mut self) -> Option<&mut Type> {