Browse Source

Add `#[track_caller]` to `GcObject` methods that can panic (#673)

pull/676/head
Halid Odat 4 years ago committed by GitHub
parent
commit
460b4a23b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      boa/src/builtins/object/gcobject.rs

4
boa/src/builtins/object/gcobject.rs

@ -55,6 +55,7 @@ impl GcObject {
///# Panics
/// Panics if the object is currently mutably borrowed.
#[inline]
#[track_caller]
pub fn borrow(&self) -> Ref<'_> {
self.try_borrow().expect("Object already mutably borrowed")
}
@ -67,6 +68,7 @@ impl GcObject {
///# Panics
/// Panics if the object is currently borrowed.
#[inline]
#[track_caller]
pub fn borrow_mut(&self) -> RefMut<'_> {
self.try_borrow_mut().expect("Object already borrowed")
}
@ -105,6 +107,7 @@ impl GcObject {
/// Panics if the object is currently mutably borrowed.
// <https://tc39.es/ecma262/#sec-prepareforordinarycall>
// <https://tc39.es/ecma262/#sec-ecmascript-function-objects-call-thisargument-argumentslist>
#[track_caller]
pub fn call(&self, this: &Value, args: &[Value], ctx: &mut Interpreter) -> Result<Value> {
let this_function_object = self.clone();
let f_body = if let Some(function) = self.borrow().as_function() {
@ -186,6 +189,7 @@ impl GcObject {
///# Panics
/// Panics if the object is currently mutably borrowed.
// <https://tc39.es/ecma262/#sec-ecmascript-function-objects-construct-argumentslist-newtarget>
#[track_caller]
pub fn construct(&self, args: &[Value], ctx: &mut Interpreter) -> Result<Value> {
let this = Object::create(self.borrow().get(&PROTOTYPE.into())).into();

Loading…
Cancel
Save