From 823028a80715ce42b7e624e8700ff7388b1b192c Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Sat, 25 Mar 2023 04:59:29 +0100 Subject: [PATCH] Make if statements return their completion values --- boa_engine/src/bytecompiler/statement/if.rs | 6 +++--- boa_engine/src/bytecompiler/statement/mod.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/boa_engine/src/bytecompiler/statement/if.rs b/boa_engine/src/bytecompiler/statement/if.rs index 73ace44ba2c..5cf93979fd8 100644 --- a/boa_engine/src/bytecompiler/statement/if.rs +++ b/boa_engine/src/bytecompiler/statement/if.rs @@ -2,11 +2,11 @@ use crate::bytecompiler::ByteCompiler; use boa_ast::statement::If; impl ByteCompiler<'_, '_> { - pub(crate) fn compile_if(&mut self, node: &If, configurable_globals: bool) { + pub(crate) fn compile_if(&mut self, node: &If, use_expr: bool, configurable_globals: bool) { self.compile_expr(node.cond(), true); let jelse = self.jump_if_false(); - self.compile_stmt(node.body(), false, configurable_globals); + self.compile_stmt(node.body(), use_expr, configurable_globals); match node.else_node() { None => { @@ -15,7 +15,7 @@ impl ByteCompiler<'_, '_> { Some(else_body) => { let exit = self.jump(); self.patch_jump(jelse); - self.compile_stmt(else_body, false, configurable_globals); + self.compile_stmt(else_body, use_expr, configurable_globals); self.patch_jump(exit); } } diff --git a/boa_engine/src/bytecompiler/statement/mod.rs b/boa_engine/src/bytecompiler/statement/mod.rs index 36688a2d1fe..bb32585a7ba 100644 --- a/boa_engine/src/bytecompiler/statement/mod.rs +++ b/boa_engine/src/bytecompiler/statement/mod.rs @@ -17,7 +17,7 @@ impl ByteCompiler<'_, '_> { pub fn compile_stmt(&mut self, node: &Statement, use_expr: bool, configurable_globals: bool) { match node { Statement::Var(var) => self.compile_var_decl(var), - Statement::If(node) => self.compile_if(node, configurable_globals), + Statement::If(node) => self.compile_if(node, use_expr, configurable_globals), Statement::ForLoop(for_loop) => { self.compile_for_loop(for_loop, None, configurable_globals); }