updated function check

This commit is contained in:
pca006132 2021-07-26 16:00:29 +08:00
parent 8d0856a58d
commit 1d13b16f94
1 changed files with 14 additions and 1 deletions

View File

@ -132,6 +132,7 @@ impl<'a> Inferencer<'a> {
Ok(()) Ok(())
} }
// check statements for proper identifier def-use and return on all paths
fn check_stmt( fn check_stmt(
&mut self, &mut self,
stmt: &Stmt<Option<Type>>, stmt: &Stmt<Option<Type>>,
@ -195,7 +196,19 @@ impl<'a> Inferencer<'a> {
} }
Ok(false) 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), _ => Ok(false),
} }
} }