Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: panic, unwrap to unwrap_or #739

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
13 changes: 13 additions & 0 deletions core/00_primordials.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,19 @@
},
);

primordials.ArrayPrototypePush = (thisArray, ...variableArgs) => {
const args = [...variableArgs];
peko-thunder marked this conversation as resolved.
Show resolved Hide resolved
for (let i = 0; i < args.length; i++) {
ObjectDefineProperty(thisArray, thisArray.length, {
peko-thunder marked this conversation as resolved.
Show resolved Hide resolved
value: args[i],
enumerable: true,
writable: true,
configurable: true,
});
}
return thisArray.length;
};

primordials.ArrayPrototypeToString = (thisArray) =>
ArrayPrototypeJoin(thisArray);

Expand Down
4 changes: 1 addition & 3 deletions core/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,7 @@ impl JsError {

// Convert them into Vec<JsStackFrame>
let mut frames: Vec<JsStackFrame> = match frames_v8 {
Some(frames_v8) => {
serde_v8::from_v8(scope, frames_v8.into()).unwrap_or(Vec::new())
}
Some(frames_v8) => serde_v8::from_v8(scope, frames_v8.into()).unwrap(),
None => vec![],
};
let mut source_line = None;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
// This test refers to the issue.
// https://github.com/denoland/deno_core/issues/744

// Using `Object.prototype.__defineSetter__()`,
// When converting from `serde_v8::from_v8` to `Vec<JsStackFrame>`,
// Panic is caused by `unwrap_failed`.
Object.prototype.__defineSetter__(0, function () {});

// Test that JavaScript syntax error statements are output with no panic
// Need to dare to make errors.
// For example, `ReferenceError: variable is not defined`.
variable;

This file was deleted.

2 changes: 1 addition & 1 deletion testing/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ integration_test!(
error_rejection_catch,
error_rejection_order,
error_ext_stack,
error_internal_method_set,
error_with_stack,
error_without_stack,
error_variable_is_not_defined,
main_module_handler,
module_types,
pending_unref_op_tla,
Expand Down