Fix missing parens around object in MemberExpression (#424)

master
Brian Ng 2017-01-22 21:29:30 -06:00 committed by Christopher Chedeau
parent b13124bed4
commit 895709b4ca
4 changed files with 7 additions and 1 deletions

View File

@ -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 (

View File

@ -46,9 +46,11 @@ var z = Object(123);
exports[`test expression.js 1`] = `
"() => ({}\`\`);
({})\`\`;
a = () => ({}).x;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(() => ({})\`\`);
({})\`\`;
a = () => ({}).x;
"
`;

View File

@ -1,2 +1,3 @@
() => ({}``);
({})``;
a = () => ({}).x;

View File

@ -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