[Pkg-javascript-commits] [uglifyjs] 231/491: fix `AST_PropAccess` in `collapse_vars` (#2370)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:51:39 UTC 2018
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.
commit f2b9c11e2a0ab3597f798cf85770e24733609b1f
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Tue Oct 17 18:33:03 2017 +0800
fix `AST_PropAccess` in `collapse_vars` (#2370)
fixes #2364
---
lib/compress.js | 4 ++-
test/compress/collapse_vars.js | 61 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index 5e391ab..3909c65 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -838,7 +838,9 @@ merge(Compressor.prototype, {
var sym;
if (node instanceof AST_Call
|| node instanceof AST_Exit
- || node instanceof AST_PropAccess && node.has_side_effects(compressor)
+ || node instanceof AST_PropAccess
+ && (node.has_side_effects(compressor)
+ || get_symbol(node).name in lvalues)
|| node instanceof AST_SymbolRef
&& (lvalues[node.name]
|| side_effects && !references_in_scope(node.definition()))
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index ec94e9f..baa18ea 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -2601,7 +2601,7 @@ prop_side_effects_2: {
]
}
-issue_2364: {
+issue_2365: {
options = {
collapse_vars: true,
pure_getters: true,
@@ -2652,3 +2652,62 @@ issue_2364: {
"1",
]
}
+
+issue_2364_1: {
+ options = {
+ collapse_vars: true,
+ pure_getters: true,
+ }
+ input: {
+ function inc(obj) {
+ return obj.count++;
+ }
+ function foo() {
+ var first = arguments[0];
+ var result = inc(first);
+ return foo.amount = first.count, result;
+ }
+ var data = {
+ count: 0,
+ };
+ var answer = foo(data);
+ console.log(foo.amount, answer);
+ }
+ expect: {
+ function inc(obj) {
+ return obj.count++;
+ }
+ function foo() {
+ var first = arguments[0];
+ var result = inc(first);
+ return foo.amount = first.count, result;
+ }
+ var data = {
+ count: 0
+ };
+ var answer = foo(data);
+ console.log(foo.amount, answer);
+ }
+ expect_stdout: "1 0"
+}
+
+issue_2364_2: {
+ options = {
+ collapse_vars: true,
+ pure_getters: true,
+ }
+ input: {
+ function callValidate() {
+ var validate = compilation.validate;
+ var result = validate.apply(null, arguments);
+ return callValidate.errors = validate.errors, result;
+ }
+ }
+ expect: {
+ function callValidate() {
+ var validate = compilation.validate;
+ var result = validate.apply(null, arguments);
+ return callValidate.errors = validate.errors, result;
+ }
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list