diff options
-rw-r--r-- | lib/ast.js | 4 | ||||
-rw-r--r-- | test/compress/classes.js | 133 |
2 files changed, 135 insertions, 2 deletions
@@ -1759,11 +1759,11 @@ var AST_SymbolLambda = DEFNODE("SymbolLambda", null, { var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, { $documentation: "Symbol defining a class", -}, AST_SymbolLet); +}, AST_SymbolConst); var AST_SymbolClass = DEFNODE("SymbolClass", null, { $documentation: "Symbol naming a class expression", -}, AST_SymbolLet); +}, AST_SymbolConst); var AST_SymbolCatch = DEFNODE("SymbolCatch", null, { $documentation: "Symbol naming the exception in catch", diff --git a/test/compress/classes.js b/test/compress/classes.js index c57842f9..d4047a8a 100644 --- a/test/compress/classes.js +++ b/test/compress/classes.js @@ -1875,3 +1875,136 @@ issue_5015_3: { expect_stdout: "PASS" node_version: ">=4" } + +issue_5053_1: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + "use strict"; + try { + console.log(new class A { + constructor() { + A = 42; + } + }()); + } catch (e) { + console.log("PASS"); + } + } + expect: { + "use strict"; + try { + console.log(new class A { + constructor() { + A = 42; + } + }()); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" + node_version: ">=4" +} + +issue_5053_2: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + "use strict"; + try { + console.log(new class A { + f() { + A = 42; + } + }().f()); + } catch (e) { + console.log("PASS"); + } + } + expect: { + "use strict"; + try { + console.log(new class A { + f() { + A = 42; + } + }().f()); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" + node_version: ">=4" +} + +issue_5053_3: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + try { + console.log(new class A { + p = A = 42; + }().p); + } catch (e) { + console.log("PASS"); + } + } + expect: { + try { + console.log(new class A { + p = A = 42; + }().p); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" + node_version: ">=12" +} + +issue_5053_4: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + "use strict"; + class A { + constructor() { + A = 42; + } + } + try { + console.log(new A()); + } catch (e) { + console.log("PASS"); + } + } + expect: { + "use strict"; + class A { + constructor() { + A = 42; + } + } + try { + console.log(new A()); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" + node_version: ">=4" +} |