updated function check

This commit is contained in:
pca006132 2021-07-26 16:00:29 +08:00
parent 8d0856a58d
commit 1d13b16f94

View File

@ -132,6 +132,7 @@ impl<'a> Inferencer<'a> {
Ok(())
}
// check statements for proper identifier def-use and return on all paths
fn check_stmt(
&mut self,
stmt: &Stmt<Option<Type>>,
@ -195,7 +196,19 @@ impl<'a> Inferencer<'a> {
}
Ok(false)
}
// break, return, raise, etc.
StmtKind::Return { value } => {
if let Some(value) = value {
self.check_expr(value, defined_identifiers)?;
}
Ok(true)
}
StmtKind::Raise { exc, .. } => {
if let Some(value) = exc {
self.check_expr(value, defined_identifiers)?;
}
Ok(true)
}
// break, raise, etc.
_ => Ok(false),
}
}