@@ -17135,21 +17135,10 @@ fn evaluate_expr_delete<'gc>(mc: &MutationContext<'gc>, env: &JSObjectDataPtr<'g
1713517135 }
1713617136
1713717137 if obj.borrow().non_configurable.contains(&key_val) {
17138- let is_function_like = obj.borrow().get_closure().is_some();
17139- if is_function_like && (key == "length" || key == "name") {
17140- if let Some(cl_ptr) = obj.borrow().get_closure()
17141- && let Value::Function(func_name) = &*cl_ptr.borrow()
17142- {
17143- mark_builtin_function_virtual_prop_deleted(mc, env, func_name, key)?;
17144- }
17145- let mut o = obj.borrow_mut(mc);
17146- let _ = o.properties.shift_remove(&key_val);
17147- let _ = o.non_configurable.remove(&key_val);
17148- let _ = o.non_writable.remove(&key_val);
17149- let _ = o.non_enumerable.remove(&key_val);
17150- Ok(Value::Boolean(true))
17151- } else {
17138+ if env_get_strictness(env) {
1715217139 Err(crate::raise_type_error!(format!("Cannot delete non-configurable property '{key}'",)).into())
17140+ } else {
17141+ Ok(Value::Boolean(false))
1715317142 }
1715417143 } else {
1715517144 let _ = obj.borrow_mut(mc).properties.shift_remove(&key_val);
@@ -17225,27 +17214,14 @@ fn evaluate_expr_delete<'gc>(mc: &MutationContext<'gc>, env: &JSObjectDataPtr<'g
1722517214 return Ok(Value::Boolean(true));
1722617215 }
1722717216 if obj.borrow().non_configurable.contains(&key) {
17228- let is_fn_length_or_name = matches!(&key, PropertyKey::String(s) if s == "length" || s == "name");
17229- let is_function_like = obj.borrow().get_closure().is_some();
17230- if is_function_like && is_fn_length_or_name {
17231- if let PropertyKey::String(s) = &key
17232- && let Some(cl_ptr) = obj.borrow().get_closure()
17233- && let Value::Function(func_name) = &*cl_ptr.borrow()
17234- {
17235- mark_builtin_function_virtual_prop_deleted(mc, env, func_name, s)?;
17236- }
17237- let mut o = obj.borrow_mut(mc);
17238- let _ = o.properties.shift_remove(&key);
17239- let _ = o.non_configurable.remove(&key);
17240- let _ = o.non_writable.remove(&key);
17241- let _ = o.non_enumerable.remove(&key);
17242- Ok(Value::Boolean(true))
17243- } else {
17217+ if env_get_strictness(env) {
1724417218 Err(crate::raise_type_error!(format!(
1724517219 "Cannot delete non-configurable property '{}'",
1724617220 value_to_string(&key_val_res)
1724717221 ))
1724817222 .into())
17223+ } else {
17224+ Ok(Value::Boolean(false))
1724917225 }
1725017226 } else {
1725117227 let _ = obj.borrow_mut(mc).properties.shift_remove(&key);
@@ -19083,7 +19059,13 @@ pub fn call_native_function<'gc>(
1908319059
1908419060 // Restricted accessor used to implement the throwing 'caller'/'arguments' accessors on Function.prototype
1908519061 if name == "Function.prototype.restrictedThrow" {
19086- return Err(raise_type_error!("Access to 'caller' or 'arguments' is restricted").into());
19062+ // Use the env passed to this function (which is the ThrowTypeError's own realm
19063+ // when called cross-realm) so the TypeError is instanceof that realm's TypeError.
19064+ return Err(throw_realm_type_error(
19065+ mc,
19066+ env,
19067+ "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them",
19068+ ));
1908719069 }
1908819070
1908919071 if name == "AsyncGenerator.prototype.next" {
@@ -19850,7 +19832,11 @@ pub(crate) fn call_accessor<'gc>(
1985019832 Value::Function(name) => {
1985119833 // Special-case restricted accessor thrower
1985219834 if name == "Function.prototype.restrictedThrow" {
19853- return Err(raise_type_error!("Access to 'caller' or 'arguments' is restricted").into());
19835+ return Err(throw_realm_type_error(
19836+ mc,
19837+ env,
19838+ "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them",
19839+ ));
1985419840 }
1985519841 if let Some(res) = call_native_function(mc, name, Some(&Value::Object(*receiver)), &[], env)? {
1985619842 Ok(res)
@@ -19864,7 +19850,11 @@ pub(crate) fn call_accessor<'gc>(
1986419850 Ok(v) => Ok(v),
1986519851 Err(_) => {
1986619852 if name.contains("restrictedThrow") {
19867- Err(raise_type_error!("Access to 'caller' or 'arguments' is restricted").into())
19853+ Err(throw_realm_type_error(
19854+ mc,
19855+ env,
19856+ "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them",
19857+ ))
1986819858 } else {
1986919859 Err(raise_type_error!(format!("Accessor function {name} not supported")).into())
1987019860 }
0 commit comments