Repository: jlongster/prettier (js)

Issue:
Missing parenthesis for functions left of a template literal
```js
(function() {})()``;
(function() {})``;
```

outputs

```js
function() {}()``;
function() {}``;
```

which is invalid

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22(function()%20%7B%7D)()%60%60%3B%5Cn(function()%20%7B%7D)%60%60%3B%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%7D%7D

Those test262 are testing crazy things :p

Pull request description:
Fix parens for functions inside TaggedTemplateExpression
Fixes #244 (again)

Sorry for missing this one!

Patch:
diff --git a/src/fast-path.js b/src/fast-path.js
index cc195dc92..94b2fcf44 100644
--- a/src/fast-path.js
+++ b/src/fast-path.js
@@ -374,6 +374,7 @@ FPp.needsParens = function(assumeExpressionContext) {
 
       switch (parent.type) {
         case "MemberExpression":
+        case "TaggedTemplateExpression":
         case "UnaryExpression":
           return true;
 


Test patch:
diff --git a/tests/arrows/__snapshots__/jsfmt.spec.js.snap b/tests/arrows/__snapshots__/jsfmt.spec.js.snap
index 3e6449a4b..9e447683e 100644
--- a/tests/arrows/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/arrows/__snapshots__/jsfmt.spec.js.snap
@@ -30,6 +30,7 @@ exports[`test arrow_function_expression.js 1`] = `
 typeof (() => {});
 export default (() => {})();
 (() => {})()\`\`;
+(() => {})\`\`;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 (a => {
 }).length;
@@ -39,6 +40,8 @@ export default (() => {
 })()
 (() => {
 })()\`\`;
+(() => {
+})\`\`;
 "
 `;
 
diff --git a/tests/arrows/arrow_function_expression.js b/tests/arrows/arrow_function_expression.js
index f0309346f..dac425060 100644
--- a/tests/arrows/arrow_function_expression.js
+++ b/tests/arrows/arrow_function_expression.js
@@ -2,3 +2,4 @@
 typeof (() => {});
 export default (() => {})();
 (() => {})()``;
+(() => {})``;
diff --git a/tests/function/__snapshots__/jsfmt.spec.js.snap b/tests/function/__snapshots__/jsfmt.spec.js.snap
index a776342cc..cb2af2b51 100644
--- a/tests/function/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/function/__snapshots__/jsfmt.spec.js.snap
@@ -356,6 +356,7 @@ exports[`test function_expression.js 1`] = `
 typeof (function() {});
 export default (function() {})();
 (function() {})()\`\`;
+(function() {})\`\`;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 (function() {
 }).length;
@@ -365,6 +366,8 @@ export default (function() {
 })()
 (function() {
 })()\`\`;
+(function() {
+})\`\`;
 "
 `;
 
diff --git a/tests/function/function_expression.js b/tests/function/function_expression.js
index 786e8bdb5..93c6da8ec 100644
--- a/tests/function/function_expression.js
+++ b/tests/function/function_expression.js
@@ -2,3 +2,4 @@
 typeof (function() {});
 export default (function() {})();
 (function() {})()``;
+(function() {})``;