From e6ea3aa53635d9d4316cb1f776f8aae8605c78ca Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Sun, 22 Oct 2023 19:42:24 -0600 Subject: [PATCH] Fix regressions --- boa_engine/src/builtins/error/type.rs | 26 +++++++++++++++++--------- boa_engine/src/builtins/regexp/mod.rs | 5 ++--- boa_engine/src/context/intrinsics.rs | 1 + 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/boa_engine/src/builtins/error/type.rs b/boa_engine/src/builtins/error/type.rs index a929cf10f7c..aab6c9c40ad 100644 --- a/boa_engine/src/builtins/error/type.rs +++ b/boa_engine/src/builtins/error/type.rs @@ -20,11 +20,12 @@ use crate::{ context::intrinsics::{Intrinsics, StandardConstructor, StandardConstructors}, error::JsNativeError, js_string, + native_function::NativeFunctionObject, object::{internal_methods::get_prototype_from_constructor, JsObject, ObjectData}, property::Attribute, realm::Realm, string::{common::StaticJsStrings, utf16}, - Context, JsArgs, JsResult, JsString, JsValue, + Context, JsArgs, JsResult, JsString, JsValue, NativeFunction, }; use boa_profiler::Profiler; @@ -115,14 +116,7 @@ pub(crate) struct ThrowTypeError; impl IntrinsicObject for ThrowTypeError { fn init(realm: &Realm) { - let obj = BuiltInBuilder::callable_with_intrinsic::(realm, |_, _, _| { - Err(JsNativeError::typ() - .with_message( - "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode \ - functions or the arguments objects for calls to them", - ) - .into()) - }) + let obj = BuiltInBuilder::with_intrinsic::(realm) .prototype(realm.intrinsics().constructors().function().prototype()) .static_property(utf16!("length"), 0, Attribute::empty()) .static_property(utf16!("name"), js_string!(), Attribute::empty()) @@ -130,6 +124,20 @@ impl IntrinsicObject for ThrowTypeError { let mut obj = obj.borrow_mut(); + *obj.as_native_function_mut() + .expect("`%ThrowTypeError%` must be a function") = NativeFunctionObject { + f: NativeFunction::from_fn_ptr(|_, _, _| { + Err(JsNativeError::typ() + .with_message( + "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode \ + functions or the arguments objects for calls to them", + ) + .into()) + }), + constructor: None, + realm: Some(realm.clone()), + }; + obj.extensible = false; } diff --git a/boa_engine/src/builtins/regexp/mod.rs b/boa_engine/src/builtins/regexp/mod.rs index 28af40163a5..0948e145c28 100644 --- a/boa_engine/src/builtins/regexp/mod.rs +++ b/boa_engine/src/builtins/regexp/mod.rs @@ -1887,13 +1887,12 @@ impl RegExp { { let mut obj = this.borrow_mut(); - // Should just override the already existing `lastIndex` property. - obj.properties_mut().storage[0] = 0.into(); - *obj.as_regexp_mut() .expect("already checked that the object was a RegExp") = regexp; } + this.set(utf16!("lastIndex"), 0, true, context)?; + Ok(this.into()) } } diff --git a/boa_engine/src/context/intrinsics.rs b/boa_engine/src/context/intrinsics.rs index 81f66b540cf..14c7ad31a63 100644 --- a/boa_engine/src/context/intrinsics.rs +++ b/boa_engine/src/context/intrinsics.rs @@ -1323,6 +1323,7 @@ pub(crate) struct ObjectTemplates { symbol: ObjectTemplate, bigint: ObjectTemplate, boolean: ObjectTemplate, + regexp: ObjectTemplate, regexp_without_proto: ObjectTemplate,