1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:08:10 +00:00

LibJS: Do not downcast from Object to RegExpObject unless needed

Several test262 tests rely on creating phony RegExp objects that do not
have the internal slots used to test for a valid RegExp object. To allow
these tests to run (and because the spec doesn't require real RegExp
objects in these methods), do not attempt to downcast where it isn't
needed.
This commit is contained in:
Timothy Flynn 2021-07-07 15:06:42 -04:00 committed by Linus Groh
parent ce2651a320
commit aaf5339fae

View file

@ -268,7 +268,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::exec)
// 22.2.5.15 RegExp.prototype.test ( S ), https://tc39.es/ecma262/#sec-regexp.prototype.test
JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::test)
{
auto* regexp_object = regexp_object_from(vm, global_object);
auto* regexp_object = this_object_from(vm, global_object);
if (!regexp_object)
return {};
@ -310,7 +310,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::to_string)
// 22.2.5.7 RegExp.prototype [ @@match ] ( string ), https://tc39.es/ecma262/#sec-regexp.prototype-@@match
JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match)
{
auto* regexp_object = regexp_object_from(vm, global_object);
auto* regexp_object = this_object_from(vm, global_object);
if (!regexp_object)
return {};
auto s = vm.argument(0).to_string(global_object);
@ -380,7 +380,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
auto string_value = vm.argument(0);
auto replace_value = vm.argument(1);
auto* regexp_object = regexp_object_from(vm, global_object);
auto* regexp_object = this_object_from(vm, global_object);
if (!regexp_object)
return {};
auto string = string_value.to_string(global_object);