Skip to content

Commit

Permalink
Fix logical expression in parenthesis
Browse files Browse the repository at this point in the history
  • Loading branch information
wyozi authored and mathiasbynens committed Aug 23, 2016
1 parent de4b36c commit 5157c09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion luamin.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@
var needsParens = base.inParens && (
type == 'BinaryExpression' ||
type == 'FunctionDeclaration' ||
type == 'TableConstructorExpression'
type == 'TableConstructorExpression' ||
type == 'LogicalExpression'
);
if (needsParens) {
result += '(';
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,11 @@
'description': 'MemberExpression + CallExpression on a TableConstructorExpression',
'original': 'x = ({ foo = print }).foo("test")',
'minified': 'x=({foo=print}).foo("test")'
},
{
'description': 'LogicalExpression in parenthesis + MemberExpression + CallExpression',
'original': '(x or y):f()',
'minified': '(x or y):f()'
}
],

Expand Down

0 comments on commit 5157c09

Please sign in to comment.