diff options
Diffstat (limited to 'cli/rt/02_console.js')
-rw-r--r-- | cli/rt/02_console.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cli/rt/02_console.js b/cli/rt/02_console.js index 363a95d90..0eb7f0aac 100644 --- a/cli/rt/02_console.js +++ b/cli/rt/02_console.js @@ -196,8 +196,13 @@ return String(value[customInspect]()); } catch {} } - // Might be Function/AsyncFunction/GeneratorFunction - const cstrName = Object.getPrototypeOf(value).constructor.name; + // Might be Function/AsyncFunction/GeneratorFunction/AsyncGeneratorFunction + let cstrName = Object.getPrototypeOf(value)?.constructor?.name; + if (!cstrName) { + // If prototype is removed or broken, + // use generic 'Function' instead. + cstrName = "Function"; + } if (value.name && value.name !== "anonymous") { // from MDN spec return `[${cstrName}: ${value.name}]`; |