mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
Revert "LibJS: Get rid of unnecessary work from canonical_numeric_index_string"
This reverts commit 3a184f7841
.
This broke a number of test262 tests under "TypedArrayConstructors".
The issue is that the CanonicalNumericIndexString AO should not fail
for inputs like "1.1", despite them not being integral indices.
This commit is contained in:
parent
b193351a99
commit
4b412e8fee
9 changed files with 105 additions and 61 deletions
|
@ -65,14 +65,16 @@ Optional<Value> PrimitiveString::get(GlobalObject& global_object, PropertyKey co
|
|||
return Value(static_cast<double>(length));
|
||||
}
|
||||
}
|
||||
auto index = canonical_numeric_index_string(property_key);
|
||||
if (!index.has_value())
|
||||
auto index = canonical_numeric_index_string(global_object, property_key);
|
||||
if (index.type() != JS::Value::Type::Int32)
|
||||
return {};
|
||||
if (index.as_i32() < 0)
|
||||
return {};
|
||||
auto str = utf16_string_view();
|
||||
auto length = str.length_in_code_units();
|
||||
if (length <= *index)
|
||||
if (static_cast<i32>(length) <= index.as_i32())
|
||||
return {};
|
||||
return js_string(vm(), str.substring_view(*index, 1));
|
||||
return js_string(vm(), str.substring_view(index.as_i32(), 1));
|
||||
}
|
||||
|
||||
PrimitiveString* js_string(Heap& heap, Utf16View const& view)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue