fix(javascript): add parens for unary in bind (#4950)
* test: add tests * fix(javascript): add parens for unary in bindmaster
parent
e72cb538f9
commit
4d2f224919
|
@ -168,6 +168,7 @@ function needsParens(path, options) {
|
|||
(node.operator === "+" || node.operator === "-")
|
||||
);
|
||||
|
||||
case "BindExpression":
|
||||
case "MemberExpression":
|
||||
return name === "object" && parent.object === node;
|
||||
|
||||
|
|
|
@ -215,3 +215,25 @@ class X {
|
|||
}
|
||||
|
||||
`;
|
||||
|
||||
exports[`unary.js - babylon-verify 1`] = `
|
||||
(void 0)::func();
|
||||
|
||||
(+0)::is(-0);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
(void 0)::func();
|
||||
|
||||
(+0)::is(-0);
|
||||
|
||||
`;
|
||||
|
||||
exports[`unary.js - babylon-verify 2`] = `
|
||||
(void 0)::func();
|
||||
|
||||
(+0)::is(-0);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
;(void 0)::func()
|
||||
|
||||
;(+0)::is(-0)
|
||||
|
||||
`;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
(void 0)::func();
|
||||
|
||||
(+0)::is(-0);
|
Loading…
Reference in New Issue