diff --git a/crates/dash_compiler/src/lib.rs b/crates/dash_compiler/src/lib.rs index 4805343b..69ed2964 100644 --- a/crates/dash_compiler/src/lib.rs +++ b/crates/dash_compiler/src/lib.rs @@ -1147,6 +1147,7 @@ impl<'interner> Visitor> for FunctionCompiler<'interner> { .cp .add_symbol(name) .map_err(|_| Error::ConstantPoolLimitExceeded(span))?; + ib.write_bool(false); // Defaults are unsupported ib.writew(var_id); ib.writew(ident_id); } @@ -1179,6 +1180,8 @@ impl<'interner> Visitor> for FunctionCompiler<'interner> { .cp .add_number(local as f64) .map_err(|_| Error::ConstantPoolLimitExceeded(span))?; + + ib.write_bool(false); // Defaults are unsupported ib.writew(var_id); } ArrayMemberKind::Spread(_) => unimplementedc!(span, "rest operator in array destructuring is unsupported"), diff --git a/crates/dash_vm/src/dispatch.rs b/crates/dash_vm/src/dispatch.rs index 3556a35b..579db910 100755 --- a/crates/dash_vm/src/dispatch.rs +++ b/crates/dash_vm/src/dispatch.rs @@ -2089,15 +2089,15 @@ mod handlers { idents.push(ident); } - let mut prop = obj.get_property(&mut cx, ident.into())?; + let mut prop = obj.get_property(&mut cx, ident.into())?.root(&mut cx.scope); if has_default { // NB: we need to at least pop it from the stack even if the property exists - let default = cx.pop_stack(); - if prop.is_undefined() { + let default = cx.pop_stack_rooted(); + if matches!(prop.unpack(), ValueKind::Undefined(_)) { prop = default; } } - cx.set_local(id as usize, prop); + cx.set_local(id as usize, prop.into()); } if let Some(rest_id) = rest_id { @@ -2132,16 +2132,16 @@ mod handlers { if let Some((has_default, NumberWConstant(id))) = id { let id = id as usize; let key = cx.scope.intern_usize(i); - let mut prop = array.get_property(&mut cx.scope, key.into())?; + let mut prop = array.get_property(&mut cx.scope, key.into())?.root(&mut cx.scope); if has_default { // NB: we need to at least pop it from the stack even if the property exists - let default = cx.pop_stack(); - if prop.is_undefined() { + let default = cx.pop_stack_rooted(); + if matches!(prop.unpack(), ValueKind::Undefined(_)) { prop = default; } } - cx.set_local(id, prop); + cx.set_local(id, prop.into()); } } diff --git a/crates/dash_vm/src/value/mod.rs b/crates/dash_vm/src/value/mod.rs index a46d4f16..4372431d 100755 --- a/crates/dash_vm/src/value/mod.rs +++ b/crates/dash_vm/src/value/mod.rs @@ -380,12 +380,6 @@ impl Unrooted { Self { value } } - /// Checks if this value is undefined. - /// As this does not require access to any garbage collected resources, this operation is safe without rooting. - pub fn is_undefined(self) -> bool { - matches!(self.value.unpack(), ValueKind::Undefined(_)) - } - /// Returns an unprotected, unrooted reference to the value. /// /// # Safety