From 5497bea3d1e25d14091a9dcb45a3aa326e4090f7 Mon Sep 17 00:00:00 2001 From: Matthias Mullie Date: Mon, 29 Jun 2015 17:48:42 +0200 Subject: [PATCH] Don't collapse line feeds after "return" return is not guaranteed to be followed by a return value. It could just be "return", followed by nothing (void return), not even a semicolon, just line feed (ASI) Whatever is next could, for example, be another operator. We may just need ASI to kick in there, so keep the line feed after return. Fixes issue #54 --- data/js/keywords_before.txt | 1 - tests/js/JSTest.php | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/data/js/keywords_before.txt b/data/js/keywords_before.txt index 098ee77..40b4ec0 100644 --- a/data/js/keywords_before.txt +++ b/data/js/keywords_before.txt @@ -15,7 +15,6 @@ delete export import public -return static typeof extends diff --git a/tests/js/JSTest.php b/tests/js/JSTest.php index 2f5934c..02ebe22 100644 --- a/tests/js/JSTest.php +++ b/tests/js/JSTest.php @@ -575,6 +575,20 @@ function foo(a,b){return a/b}', return !1;return !0}', ); + // https://github.com/matthiasmullie/minify/issues/54 + $tests[] = array( + 'function a() { + if (true) + return + if (false) + return +}', + 'function a(){if(!0) +return +if(!1) +return}', + ); + return $tests; } }