Skip to content

Commit

Permalink
Fix regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Oct 23, 2023
1 parent 02adff4 commit e6ea3aa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
26 changes: 17 additions & 9 deletions boa_engine/src/builtins/error/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -115,21 +116,28 @@ pub(crate) struct ThrowTypeError;

impl IntrinsicObject for ThrowTypeError {
fn init(realm: &Realm) {
let obj = BuiltInBuilder::callable_with_intrinsic::<Self>(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::<Self>(realm)
.prototype(realm.intrinsics().constructors().function().prototype())
.static_property(utf16!("length"), 0, Attribute::empty())
.static_property(utf16!("name"), js_string!(), Attribute::empty())
.build();

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;
}

Expand Down
5 changes: 2 additions & 3 deletions boa_engine/src/builtins/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand Down
1 change: 1 addition & 0 deletions boa_engine/src/context/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@ pub(crate) struct ObjectTemplates {
symbol: ObjectTemplate,
bigint: ObjectTemplate,
boolean: ObjectTemplate,

regexp: ObjectTemplate,
regexp_without_proto: ObjectTemplate,

Expand Down

0 comments on commit e6ea3aa

Please sign in to comment.