From fd889fd5d0dea8e139826a1b4cff06d610d1aeeb Mon Sep 17 00:00:00 2001 From: Halid Odat Date: Wed, 2 Mar 2022 11:24:13 +0000 Subject: [PATCH] Fix `PropertyKey` to `JsValue` conversion (#1886) We store string `PropertyKey`s with two enums `String` and `Index` for performance reasons, but the spec does not differentiate between string and index property keys so before conversion to `JsValue` we have to convert to a string. This was failing tests like `Reflect.ownKeys([true, "", 1])` because it was returning (integer numbers) `[1, 2, 3]` instead of `['1', '2', '3']` --- boa_engine/src/property/mod.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/boa_engine/src/property/mod.rs b/boa_engine/src/property/mod.rs index bad7e73268..a35a214505 100644 --- a/boa_engine/src/property/mod.rs +++ b/boa_engine/src/property/mod.rs @@ -580,13 +580,7 @@ impl From for JsValue { match property_key { PropertyKey::String(ref string) => string.clone().into(), PropertyKey::Symbol(ref symbol) => symbol.clone().into(), - PropertyKey::Index(index) => { - if let Ok(integer) = i32::try_from(index) { - Self::new(integer) - } else { - Self::new(index) - } - } + PropertyKey::Index(index) => index.to_string().into(), } } }