Fix missing parens around object in MemberExpression (#424)
parent
b13124bed4
commit
895709b4ca
|
@ -463,6 +463,9 @@ FPp.needsParens = function(assumeExpressionContext) {
|
|||
if (parent.type === "TaggedTemplateExpression") {
|
||||
return true;
|
||||
}
|
||||
if (parent.type === "MemberExpression") {
|
||||
return name === "object" && parent.object === node;
|
||||
}
|
||||
|
||||
default:
|
||||
if (
|
||||
|
|
|
@ -46,9 +46,11 @@ var z = Object(123);
|
|||
exports[`test expression.js 1`] = `
|
||||
"() => ({}\`\`);
|
||||
({})\`\`;
|
||||
a = () => ({}).x;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
(() => ({})\`\`);
|
||||
({})\`\`;
|
||||
a = () => ({}).x;
|
||||
"
|
||||
`;
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
() => ({}``);
|
||||
({})``;
|
||||
a = () => ({}).x;
|
||||
|
|
|
@ -2565,7 +2565,7 @@ let tests = [
|
|||
if (x.kind === null.toString()) {
|
||||
}
|
||||
// error, method on null
|
||||
if ({ kind: 1 }.kind === null.toString()) {
|
||||
if (({ kind: 1 }).kind === null.toString()) {
|
||||
} // error, method on null
|
||||
},
|
||||
// non-objects on LHS
|
||||
|
|
Loading…
Reference in New Issue