[Pkg-javascript-commits] [uglifyjs] 89/228: fix return from recursive IIFE (#1570)
Jonas Smedegaard
dr at jones.dk
Sat Apr 15 14:25:19 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 bd6dee52abd607244d89f606a729e811a9b0b478
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Wed Mar 8 03:31:51 2017 +0800
fix return from recursive IIFE (#1570)
`side-effects` did not account for IIFEs being able to reference itself thus making its return value potentially significant
---
lib/compress.js | 3 ++-
test/compress/issue-1569.js | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/lib/compress.js b/lib/compress.js
index 8bbbc3f..85b457e 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2100,7 +2100,8 @@ merge(Compressor.prototype, {
def(AST_This, return_null);
def(AST_Call, function(compressor, first_in_statement){
if (!this.has_pure_annotation(compressor) && compressor.pure_funcs(this)) {
- if (this.expression instanceof AST_Function) {
+ if (this.expression instanceof AST_Function
+ && (!this.expression.name || !this.expression.name.definition().references.length)) {
var node = this.clone();
node.expression = node.expression.process_expression(false);
return node;
diff --git a/test/compress/issue-1569.js b/test/compress/issue-1569.js
new file mode 100644
index 0000000..5f0bca3
--- /dev/null
+++ b/test/compress/issue-1569.js
@@ -0,0 +1,19 @@
+inner_reference: {
+ options = {
+ side_effects: true,
+ }
+ input: {
+ !function f(a) {
+ return a && f(a - 1) + a;
+ }(42);
+ !function g(a) {
+ return a;
+ }(42);
+ }
+ expect: {
+ !function f(a) {
+ return a && f(a - 1) + a;
+ }(42);
+ !void 0;
+ }
+}
--
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