[Pkg-javascript-commits] [uglifyjs] 156/228: fix `cascade` on anonymous function reference (#1693)
Jonas Smedegaard
dr at jones.dk
Sat Apr 15 14:25:26 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository uglifyjs.
commit f001e4cb9d5bfe56e25db552bb7ab0951a142a99
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Mon Mar 27 01:58:21 2017 +0800
fix `cascade` on anonymous function reference (#1693)
Unlike normal variables and even function definitions, these cannot be reassigned, even though assignment expressions would "leak" the assigned value as normal.
---
lib/compress.js | 4 +-
test/compress/sequences.js | 110 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 113 insertions(+), 1 deletion(-)
diff --git a/lib/compress.js b/lib/compress.js
index 590015f..8350ba2 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2922,7 +2922,9 @@ merge(Compressor.prototype, {
&& (self.car.operator == "++" || self.car.operator == "--")) {
left = self.car.expression;
}
- if (left) {
+ if (left
+ && !(left instanceof AST_SymbolRef
+ && left.definition().orig[0] instanceof AST_SymbolLambda)) {
var parent, field;
var cdr = self.cdr;
while (true) {
diff --git a/test/compress/sequences.js b/test/compress/sequences.js
index af6e0c3..f1fa0e8 100644
--- a/test/compress/sequences.js
+++ b/test/compress/sequences.js
@@ -330,3 +330,113 @@ issue_1685: {
}
expect_stdout: true
}
+
+func_def_1: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ function f() {
+ return f = 0, !!f;
+ }
+ console.log(f());
+ }
+ expect: {
+ function f() {
+ return !!(f = 0);
+ }
+ console.log(f());
+ }
+ expect_stdout: "false"
+}
+
+func_def_2: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ console.log(function f() {
+ return f = 0, !!f;
+ }());
+ }
+ expect: {
+ console.log(function f() {
+ return f = 0, !!f;
+ }());
+ }
+ expect_stdout: "true"
+}
+
+func_def_3: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ function f() {
+ function g() {}
+ return g = 0, !!g;
+ }
+ console.log(f());
+ }
+ expect: {
+ function f() {
+ function g() {}
+ return !!(g = 0);
+ }
+ console.log(f());
+ }
+ expect_stdout: "false"
+}
+
+func_def_4: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ function f() {
+ function g() {
+ return g = 0, !!g;
+ }
+ return g();
+ }
+ console.log(f());
+ }
+ expect: {
+ function f() {
+ function g() {
+ return !!(g = 0);
+ }
+ return g();
+ }
+ console.log(f());
+ }
+ expect_stdout: "false"
+}
+
+func_def_5: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ function f() {
+ return function g(){
+ return g = 0, !!g;
+ }();
+ }
+ console.log(f());
+ }
+ expect: {
+ function f() {
+ return function g(){
+ return g = 0, !!g;
+ }();
+ }
+ console.log(f());
+ }
+ expect_stdout: "true"
+}
--
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