Skip to content

Commit

Permalink
Don't collapse line feeds after "return"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matthiasmullie committed Jun 29, 2015
1 parent 894928f commit 5497bea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 0 additions & 1 deletion data/js/keywords_before.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ delete
export
import
public
return
static
typeof
extends
Expand Down
14 changes: 14 additions & 0 deletions tests/js/JSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 5497bea

Please sign in to comment.