From: Alex Lam S.L Date: Tue, 18 Aug 2020 22:14:41 +0000 (+0100) Subject: avoid setters during `console.log()` in sandbox (#4055) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e8db526f513ba324535fff040d651d4faacd89ae;p=UglifyJS.git avoid setters during `console.log()` in sandbox (#4055) fixes #4054 --- diff --git a/test/compress/sandbox.js b/test/compress/sandbox.js index 02097c1e..9356f6f3 100644 --- a/test/compress/sandbox.js +++ b/test/compress/sandbox.js @@ -80,3 +80,21 @@ log_global: { } expect_stdout: "[object global]" } + +issue_4054: { + input: { + console.log({ + set p(v) { + throw "FAIL"; + }, + }); + } + expect: { + console.log({ + set p(v) { + throw "FAIL"; + }, + }); + } + expect_stdout: "{ p: [Setter] }" +} diff --git a/test/sandbox.js b/test/sandbox.js index 2f9ec677..c1575783 100644 --- a/test/sandbox.js +++ b/test/sandbox.js @@ -40,7 +40,7 @@ function createContext() { arg.constructor.toString(); if (level--) for (var key in arg) { var desc = Object.getOwnPropertyDescriptor(arg, key); - if (!desc || !desc.get) arg[key] = safe_log(arg[key], level); + if (!desc || !desc.get && !desc.set) arg[key] = safe_log(arg[key], level); } } return arg;