From bb3eecd1908fef6e1a534e3ca8e37de4ba4671cd Mon Sep 17 00:00:00 2001 From: John Date: Mon, 26 Feb 2024 15:53:45 -0600 Subject: [PATCH] interpreter: Allow statements to choose their own return value (reduces code duplication) --- libconlang/src/interpreter.rs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/libconlang/src/interpreter.rs b/libconlang/src/interpreter.rs index a41f26a..0f76329 100644 --- a/libconlang/src/interpreter.rs +++ b/libconlang/src/interpreter.rs @@ -649,18 +649,7 @@ pub mod interpret { let mut env = env.frame("block"); let mut out = ConValue::Empty; for stmt in stmts { - let Stmt { kind, semi, .. } = stmt; - out = match (kind, semi) { - (StmtKind::Expr(_), Semi::Unterminated) => stmt.interpret(&mut env)?, - (StmtKind::Expr(_), _) => { - stmt.interpret(&mut env)?; - ConValue::Empty - } - _ => { - stmt.interpret(&mut env)?; - continue; - } - } + out = stmt.interpret(&mut env)?; } Ok(out) }