[Pkg-javascript-commits] [uglifyjs] 297/491: fix `inline` on nested substitutions (#2533)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:51:46 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 bc5047c1e70594ea2fa8e747945a577298715926
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Wed Nov 29 13:31:41 2017 +0800
fix `inline` on nested substitutions (#2533)
fixes #2531
---
lib/compress.js | 4 ++
test/compress/functions.js | 99 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 103 insertions(+)
diff --git a/lib/compress.js b/lib/compress.js
index 5b26de8..dc76194 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2268,6 +2268,10 @@ merge(Compressor.prototype, {
self.walk(new TreeWalker(function(node) {
if (!result) return true;
if (node instanceof AST_SymbolRef) {
+ if (self.inlined) {
+ result = false;
+ return true;
+ }
var def = node.definition();
if (member(def, self.enclosed)
&& !self.variables.has(def.name)) {
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 3e5562a..3ecb4bc 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -554,3 +554,102 @@ issue_2428: {
"PASS",
]
}
+
+issue_2531_1: {
+ options = {
+ evaluate: true,
+ inline: true,
+ reduce_funcs: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ function outer() {
+ function inner(value) {
+ function closure() {
+ return value;
+ }
+ return function() {
+ return closure();
+ };
+ }
+ return inner("Hello");
+ }
+ console.log("Greeting:", outer()());
+ }
+ expect: {
+ function outer() {
+ return function(value) {
+ return function() {
+ return value;
+ };
+ }("Hello");
+ }
+ console.log("Greeting:", outer()());
+ }
+ expect_stdout: "Greeting: Hello"
+}
+
+issue_2531_2: {
+ options = {
+ evaluate: true,
+ inline: true,
+ passes: 2,
+ reduce_funcs: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ function outer() {
+ function inner(value) {
+ function closure() {
+ return value;
+ }
+ return function() {
+ return closure();
+ };
+ }
+ return inner("Hello");
+ }
+ console.log("Greeting:", outer()());
+ }
+ expect: {
+ function outer() {
+ return function() {
+ return "Hello";
+ };
+ }
+ console.log("Greeting:", outer()());
+ }
+ expect_stdout: "Greeting: Hello"
+}
+
+issue_2531_3: {
+ options = {
+ evaluate: true,
+ inline: true,
+ passes: 2,
+ reduce_funcs: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function outer() {
+ function inner(value) {
+ function closure() {
+ return value;
+ }
+ return function() {
+ return closure();
+ };
+ }
+ return inner("Hello");
+ }
+ console.log("Greeting:", outer()());
+ }
+ expect: {
+ console.log("Greeting:", "Hello");
+ }
+ expect_stdout: "Greeting: Hello"
+}
--
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