diff --git a/core/00_primordials.js b/core/00_primordials.js index 1afbb0552..910958f7c 100644 --- a/core/00_primordials.js +++ b/core/00_primordials.js @@ -487,6 +487,19 @@ }, ); + primordials.ArrayPrototypePush = (thisArray, ...args) => { + for (let i = 0; i < args.length; i++) { + ObjectDefineProperty(thisArray, thisArray.length, { + __proto__: null, + value: args[i], + enumerable: true, + writable: true, + configurable: true, + }); + } + return thisArray.length; + }; + primordials.ArrayPrototypeToString = (thisArray) => ArrayPrototypeJoin(thisArray); diff --git a/core/error.rs b/core/error.rs index 9b5340886..ecb5f7109 100644 --- a/core/error.rs +++ b/core/error.rs @@ -457,7 +457,9 @@ impl JsError { // Convert them into Vec let mut frames: Vec = match frames_v8 { - Some(frames_v8) => serde_v8::from_v8(scope, frames_v8.into()).unwrap(), + Some(frames_v8) => { + serde_v8::from_v8(scope, frames_v8.into()).unwrap_or(Vec::new()) + } None => vec![], }; let mut source_line = None; diff --git a/testing/integration/error_internal_method_set/error_internal_method_set.out b/testing/integration/error_internal_method_set/error_internal_method_set.out new file mode 100644 index 000000000..4d41d3ee1 --- /dev/null +++ b/testing/integration/error_internal_method_set/error_internal_method_set.out @@ -0,0 +1,2 @@ +[ERR] ReferenceError: variable is not defined +[ERR] at test:///integration/error_internal_method_set/error_internal_method_set.ts:11:1 diff --git a/testing/integration/error_internal_method_set/error_internal_method_set.ts b/testing/integration/error_internal_method_set/error_internal_method_set.ts new file mode 100644 index 000000000..c44697cac --- /dev/null +++ b/testing/integration/error_internal_method_set/error_internal_method_set.ts @@ -0,0 +1,11 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// @ts-nocheck: For error validation + +// This test refers to the issue. +// https://github.com/denoland/deno_core/issues/744 + +Object.prototype.__defineSetter__(0, function () {}); + +// Need to dare to make errors. +// For example, `ReferenceError: variable is not defined`. +variable; diff --git a/testing/lib.rs b/testing/lib.rs index 065502206..564e31741 100644 --- a/testing/lib.rs +++ b/testing/lib.rs @@ -59,6 +59,7 @@ integration_test!( error_rejection_catch, error_rejection_order, error_ext_stack, + error_internal_method_set, error_with_stack, error_without_stack, main_module_handler,