From d794edfeb20e026cf2d6580094ebdcb7e9ebe0cc Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Mon, 20 Mar 2023 06:03:13 +0000 Subject: [PATCH] Fix Object constructor (#2694) This Pull Request changes the following: - Add the additional required condition in the Object constructor that checks if the `NewTarget` is the Object constructor itself. --- boa_engine/src/builtins/object/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/boa_engine/src/builtins/object/mod.rs b/boa_engine/src/builtins/object/mod.rs index 02871e5ff4..daa35e7696 100644 --- a/boa_engine/src/builtins/object/mod.rs +++ b/boa_engine/src/builtins/object/mod.rs @@ -129,7 +129,11 @@ impl BuiltInConstructor for Object { context: &mut Context<'_>, ) -> JsResult { // 1. If NewTarget is neither undefined nor the active function object, then - if !new_target.is_undefined() { + if !new_target.is_undefined() + && !new_target.as_object().map_or(false, |o| { + o.eq(&context.intrinsics().constructors().object().constructor()) + }) + { // a. Return ? OrdinaryCreateFromConstructor(NewTarget, "%Object.prototype%"). let prototype = get_prototype_from_constructor(new_target, StandardConstructors::object, context)?;