Skip to content

Commit

Permalink
Fix PropertyKey to JsValue conversion (#1886)
Browse files Browse the repository at this point in the history
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']`
  • Loading branch information
HalidOdat committed Mar 2, 2022
1 parent 7248ed1 commit fd889fd
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions boa_engine/src/property/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,7 @@ impl From<PropertyKey> 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(),
}
}
}
Expand Down

0 comments on commit fd889fd

Please sign in to comment.