From f749863cb2f670010bb36d1ebf3c7bc90079d1a0 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Wed, 8 Jun 2022 20:01:00 +0100 Subject: [PATCH] document ECMAScript quirks (#5501) closes #5500 --- README.md | 10 ++++++++++ test/ufuzz/index.js | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c450fd7..2a3c4de6 100644 --- a/README.md +++ b/README.md @@ -1429,3 +1429,13 @@ To allow for better optimizations, the compiler makes various assumptions: // Actual: "undefined 42" ``` UglifyJS may modify the input which in turn may suppress those errors. +- Later versions of JavaScript will throw `SyntaxError` with the following: + ```javascript + "use strict"; + console.log(function f() { + return f = "PASS"; + }()); + // Expected: "PASS" + // Actual: TypeError: invalid assignment to const 'f' + ``` + UglifyJS may modify the input which in turn may suppress those errors. diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js index 1a13c691..4c981fa3 100644 --- a/test/ufuzz/index.js +++ b/test/ufuzz/index.js @@ -2127,7 +2127,9 @@ function errorln(msg) { } function try_beautify(code, toplevel, result, printfn, options) { - var beautified = UglifyJS.minify(code, JSON.parse(beautify_options)); + var o = JSON.parse(beautify_options); + if (async && has_await) o.module = true; + var beautified = UglifyJS.minify(code, o); if (beautified.error) { printfn("// !!! beautify failed !!!"); printfn(beautified.error);