From 1d13b16f945c98a6f54909d443e95acf44060169 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Mon, 26 Jul 2021 16:00:29 +0800 Subject: [PATCH] updated function check --- nac3core/src/typecheck/function_check.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nac3core/src/typecheck/function_check.rs b/nac3core/src/typecheck/function_check.rs index 7d3a37294..e0db2afd1 100644 --- a/nac3core/src/typecheck/function_check.rs +++ b/nac3core/src/typecheck/function_check.rs @@ -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>, @@ -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), } }