From 0e6bb74d641a5c3282b1181cc7fd6f7f3796a32a Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Sun, 25 Sep 2022 22:50:56 +0200 Subject: [PATCH] Fix some Array spec deviations --- boa_engine/src/builtins/array/mod.rs | 17 +++++++++++------ test_ignore.txt | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/boa_engine/src/builtins/array/mod.rs b/boa_engine/src/builtins/array/mod.rs index 54f22800296..cf325236366 100644 --- a/boa_engine/src/builtins/array/mod.rs +++ b/boa_engine/src/builtins/array/mod.rs @@ -346,11 +346,16 @@ impl Array { let c = original_array.get("constructor", context)?; // 4. If IsConstructor(C) is true, then - // a. Let thisRealm be the current Realm Record. - // b. Let realmC be ? GetFunctionRealm(C). - // c. If thisRealm and realmC are not the same Realm Record, then - // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined. - // TODO: Step 4 is ignored, as there are no different realms for now + if let Some(c) = c.as_constructor() { + // a. Let thisRealm be the current Realm Record. + // b. Let realmC be ? GetFunctionRealm(C). + // c. If thisRealm and realmC are not the same Realm Record, then + if *c == context.intrinsics().constructors().array().constructor { + // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined. + // Note: fast path to step 6. + return Self::array_create(length, None, context); + } + } // 5. If Type(C) is Object, then let c = if let Some(c) = c.as_object() { @@ -1224,7 +1229,7 @@ impl Array { let k_value = o.get(k, context)?; // ii. Let mappedValue be ? Call(callbackfn, thisArg, « kValue, 𝔽(k), O »). let mapped_value = - callback.call(this_arg, &[k_value, k.into(), this.into()], context)?; + callback.call(this_arg, &[k_value, k.into(), o.clone().into()], context)?; // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). a.create_data_property_or_throw(k, mapped_value, context)?; } diff --git a/test_ignore.txt b/test_ignore.txt index d84cc0e5fc3..c30babae782 100644 --- a/test_ignore.txt +++ b/test_ignore.txt @@ -12,6 +12,7 @@ feature:FinalizationRegistry feature:Atomics feature:dynamic_import feature:decorators +feature:array-grouping // Non-implemented Intl features feature:intl-normative-optional