Browse Source

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']`
pull/1889/head
Halid Odat 3 years ago
parent
commit
fd889fd5d0
  1. 8
      boa_engine/src/property/mod.rs

8
boa_engine/src/property/mod.rs

@ -580,13 +580,7 @@ impl From<PropertyKey> for JsValue {
match property_key { match property_key {
PropertyKey::String(ref string) => string.clone().into(), PropertyKey::String(ref string) => string.clone().into(),
PropertyKey::Symbol(ref symbol) => symbol.clone().into(), PropertyKey::Symbol(ref symbol) => symbol.clone().into(),
PropertyKey::Index(index) => { PropertyKey::Index(index) => index.to_string().into(),
if let Ok(integer) = i32::try_from(index) {
Self::new(integer)
} else {
Self::new(index)
}
}
} }
} }
} }

Loading…
Cancel
Save