diff --git a/boa_engine/src/builtins/eval/mod.rs b/boa_engine/src/builtins/eval/mod.rs index 9ec532ec7a0..f81257756ef 100644 --- a/boa_engine/src/builtins/eval/mod.rs +++ b/boa_engine/src/builtins/eval/mod.rs @@ -81,14 +81,10 @@ impl Eval { // Because of implementation details the following code differs from the spec. - // Parse the script body (11.a - 11.d) - // TODO: Implement errors for 11.e - 11.h - let body = match context - .parse_eval(x.as_bytes(), direct, strict) - .map_err(|e| e.to_string()) - { + // Parse the script body and handle early errors (6 - 11) + let body = match context.parse_eval(x.as_bytes(), direct, strict) { Ok(body) => body, - Err(e) => return context.throw_syntax_error(e), + Err(e) => return context.throw_syntax_error(e.to_string()), }; // 12 - 13 are implicit in the call of `Context::compile_with_new_declarative`. diff --git a/boa_engine/src/builtins/function/mod.rs b/boa_engine/src/builtins/function/mod.rs index be2b4883301..b983cbee4a3 100644 --- a/boa_engine/src/builtins/function/mod.rs +++ b/boa_engine/src/builtins/function/mod.rs @@ -264,9 +264,9 @@ impl Function { } /// Sets the `[[HomeObject]]` slot if present. - pub(crate) fn set_home_object(&mut self, object: &JsObject) { + pub(crate) fn set_home_object(&mut self, object: JsObject) { if let Self::Ordinary { home_object, .. } = self { - *home_object = Some(object.clone()); + *home_object = Some(object); } } diff --git a/boa_engine/src/vm/mod.rs b/boa_engine/src/vm/mod.rs index 4ef2b31694c..e145f9669f3 100644 --- a/boa_engine/src/vm/mod.rs +++ b/boa_engine/src/vm/mod.rs @@ -260,7 +260,7 @@ impl Context { let class_function = class_object_mut .as_function_mut() .expect("class must be function object"); - class_function.set_home_object(&proto); + class_function.set_home_object(proto.clone()); } proto @@ -288,7 +288,7 @@ impl Context { .borrow_mut() .as_function_mut() .expect("must be function object") - .set_home_object(home_object); + .set_home_object(home_object.clone()); self.vm.push(home); self.vm.push(function); @@ -802,7 +802,7 @@ impl Context { .borrow_mut() .as_function_mut() .expect("method must be function object") - .set_home_object(&object); + .set_home_object(object.clone()); let name = self.vm.frame().code.names[index as usize]; let name = self.interner().resolve_expect(name); object.__define_own_property__( @@ -865,7 +865,7 @@ impl Context { .borrow_mut() .as_function_mut() .expect("method must be function object") - .set_home_object(&object); + .set_home_object(object.clone()); let key = key.to_property_key(self)?; object.__define_own_property__( key, @@ -912,7 +912,7 @@ impl Context { .borrow_mut() .as_function_mut() .expect("method must be function object") - .set_home_object(&object); + .set_home_object(object.clone()); let name = self.vm.frame().code.names[index as usize]; let name = self.interner().resolve_expect(name).into(); let set = object @@ -964,7 +964,7 @@ impl Context { .borrow_mut() .as_function_mut() .expect("method must be function object") - .set_home_object(&object); + .set_home_object(object.clone()); let name = key.to_property_key(self)?; let set = object .__get_own_property__(&name, self)? @@ -1016,7 +1016,7 @@ impl Context { .borrow_mut() .as_function_mut() .expect("method must be function object") - .set_home_object(&object); + .set_home_object(object.clone()); let name = self.vm.frame().code.names[index as usize]; let name = self.interner().resolve_expect(name).into(); let get = object @@ -1068,7 +1068,7 @@ impl Context { .borrow_mut() .as_function_mut() .expect("method must be function object") - .set_home_object(&object); + .set_home_object(object.clone()); let name = key.to_property_key(self)?; let get = object .__get_own_property__(&name, self)? @@ -1228,7 +1228,7 @@ impl Context { let class_object = class_value .as_object() .expect("class must be function object"); - field_function.set_home_object(class_object); + field_function.set_home_object(class_object.clone()); class_object .borrow_mut() .as_function_mut() @@ -1254,7 +1254,7 @@ impl Context { let class_object = class_value .as_object() .expect("class must be function object"); - field_function.set_home_object(class_object); + field_function.set_home_object(class_object.clone()); class_object .borrow_mut() .as_function_mut()