Skip to content

Commit

Permalink
return the value of the expression in the if statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
nulluser committed Jun 2, 2024
1 parent cace1d4 commit 7ccbca7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/backend/eval/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,20 @@ pub fn evaluate_if_expr(
if condition_bool.value {
// Evaluate the consequent block if the condition is true
for stmt in then {
evaluate(stmt, env);
let result = evaluate(stmt, env);
match result {
Val::Null(_) => {}
val => return val,
}
}
} else if let Some(alt) = else_stmt {
// Evaluate the alternative block if the condition is false and an alternative is provided
for stmt in alt {
evaluate(stmt, env);
let result = evaluate(stmt, env);
match result {
Val::Null(_) => {}
val => return val,
}
}
}
} else {
Expand Down

0 comments on commit 7ccbca7

Please sign in to comment.