Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Make if statements return their completion values #2739

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions boa_engine/src/bytecompiler/statement/if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/bytecompiler/statement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down