diff --git a/boa_engine/src/builtins/error/mod.rs b/boa_engine/src/builtins/error/mod.rs index 3bfca5bdafb..b1e141f0a41 100644 --- a/boa_engine/src/builtins/error/mod.rs +++ b/boa_engine/src/builtins/error/mod.rs @@ -68,6 +68,8 @@ pub enum ErrorKind { Reference, Syntax, Uri, + #[cfg(feature = "fuzz")] + NoInstructionsRemain, } /// Built-in `Error` object. diff --git a/boa_engine/src/context/intrinsics.rs b/boa_engine/src/context/intrinsics.rs index e8d7dac720e..72fd8fce04a 100644 --- a/boa_engine/src/context/intrinsics.rs +++ b/boa_engine/src/context/intrinsics.rs @@ -97,6 +97,8 @@ pub struct StandardConstructors { syntax_error: StandardConstructor, eval_error: StandardConstructor, uri_error: StandardConstructor, + #[cfg(feature = "fuzz")] + no_instructions_remain_error: StandardConstructor, aggregate_error: StandardConstructor, map: StandardConstructor, set: StandardConstructor, @@ -156,6 +158,8 @@ impl Default for StandardConstructors { syntax_error: StandardConstructor::default(), eval_error: StandardConstructor::default(), uri_error: StandardConstructor::default(), + #[cfg(feature = "fuzz")] + no_instructions_remain_error: StandardConstructor::default(), aggregate_error: StandardConstructor::default(), map: StandardConstructor::default(), set: StandardConstructor::default(), @@ -308,6 +312,12 @@ impl StandardConstructors { &self.uri_error } + #[cfg(feature = "fuzz")] + #[inline] + pub fn no_instructions_remain_error(&self) -> &StandardConstructor { + &self.no_instructions_remain_error + } + #[inline] pub fn aggregate_error(&self) -> &StandardConstructor { &self.aggregate_error diff --git a/boa_engine/src/error.rs b/boa_engine/src/error.rs index 115a52f6672..2ad6289f69d 100644 --- a/boa_engine/src/error.rs +++ b/boa_engine/src/error.rs @@ -229,6 +229,8 @@ impl JsError { ErrorKind::Reference => JsNativeErrorKind::Reference, ErrorKind::Syntax => JsNativeErrorKind::Syntax, ErrorKind::Uri => JsNativeErrorKind::Uri, + #[cfg(feature = "fuzz")] + ErrorKind::NoInstructionsRemain => JsNativeErrorKind::NoInstructionsRemain, ErrorKind::Aggregate => { let errors = obj.get("errors", context).map_err(|e| { TryNativeError::InaccessibleProperty { @@ -634,7 +636,10 @@ impl JsNativeError { JsNativeErrorKind::NoInstructionsRemain => { // we can propagate out from try/catch since the catch block will also perform some // operation - (constructors.error().prototype(), ErrorKind::Error) + ( + constructors.no_instructions_remain_error().prototype(), + ErrorKind::NoInstructionsRemain, + ) } };