diff --git a/packages/babel-parser/src/parser/error-message.js b/packages/babel-parser/src/parser/error-message.js index 8b7f1c6182c6..4fb6c3ddfcce 100644 --- a/packages/babel-parser/src/parser/error-message.js +++ b/packages/babel-parser/src/parser/error-message.js @@ -134,6 +134,7 @@ export const ErrorMessages = makeErrorTemplates( ParamDupe: "Argument name clash.", PatternHasAccessor: "Object pattern can't contain getter or setter.", PatternHasMethod: "Object pattern can't contain methods.", + // This error is only used by the smart-mix proposal PipeBodyIsTighter: "Unexpected %0 after pipeline body; any %0 expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.", PipeTopicRequiresHackPipes: @@ -144,6 +145,8 @@ export const ErrorMessages = makeErrorTemplates( 'Invalid topic token %0. In order to use %0 as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "%0" }.', PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.", + PipeUnparenthesizedBody: + "Hack-style pipe body cannot be an unparenthesized %0 expression; please wrap it in parentheses.", // Messages whose codes start with “Pipeline” or “PrimaryTopic” // are retained for backwards compatibility diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index ae93eac117fa..0967efbd3cfa 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -61,6 +61,13 @@ import { cloneIdentifier } from "./node"; import type { SourceType } from "../options"; */ +const invalidHackPipeBodies = new Map([ + ["ArrowFunctionExpression", "arrow function"], + ["AssignmentExpression", "assignment"], + ["ConditionalExpression", "conditional"], + ["YieldExpression", "yield"], +]); + export default class ExpressionParser extends LValParser { // Forward-declaration: defined in statement.js /*:: @@ -285,28 +292,6 @@ export default class ExpressionParser extends LValParser { const operator = this.state.value; node.operator = operator; - const leftIsHackPipeExpression = - left.type === "BinaryExpression" && - left.operator === "|>" && - this.getPluginOption("pipelineOperator", "proposal") === "hack"; - - if (leftIsHackPipeExpression) { - // If the pipelinePlugin is configured to use Hack pipes, - // and if an assignment expression’s LHS invalidly contains `|>`, - // then the user likely meant to parenthesize the assignment expression. - // Throw a human-friendly error - // instead of something like 'Invalid left-hand side'. - // For example, `x = x |> y = #` (assuming `#` is the topic reference) - // groups into `x = (x |> y) = #`, - // and `(x |> y)` is an invalid assignment LHS. - // This is because Hack-style `|>` has tighter precedence than `=>`. - // (Unparenthesized `yield` expressions are handled - // in `parseHackPipeBody`, - // and unparenthesized `=>` expressions are handled - // in `checkHackPipeBodyEarlyErrors`.) - throw this.raise(this.state.start, Errors.PipeBodyIsTighter, operator); - } - if (this.match(tt.eq)) { node.left = this.toAssignable(left, /* isLHS */ true); refExpressionErrors.doubleProto = -1; // reset because double __proto__ is valid in assignment expression @@ -497,16 +482,20 @@ export default class ExpressionParser extends LValParser { switch (this.getPluginOption("pipelineOperator", "proposal")) { case "hack": return this.withTopicBindingContext(() => { - const bodyExpr = this.parseHackPipeBody(op, prec); - this.checkHackPipeBodyEarlyErrors(startPos); - return bodyExpr; + return this.parseHackPipeBody(); }); case "smart": return this.withTopicBindingContext(() => { - const childExpr = this.parseHackPipeBody(op, prec); + if (this.prodParam.hasYield && this.isContextual("yield")) { + throw this.raise( + this.state.start, + Errors.PipeBodyIsTighter, + this.state.value, + ); + } return this.parseSmartPipelineBodyInStyle( - childExpr, + this.parseExprOpBaseRightExpr(op, prec), startPos, startLoc, ); @@ -539,37 +528,25 @@ export default class ExpressionParser extends LValParser { ); } - // Helper function for `parseExprOpRightExpr` for the Hack-pipe operator - // (and the Hack-style smart-mix pipe operator). - - parseHackPipeBody(op: TokenType, prec: number): N.Expression { - // If the following expression is invalidly a `yield` expression, - // then throw a human-friendly error. - // A `yield` expression in a generator context (i.e., a [Yield] production) - // starts a YieldExpression. - // Outside of a generator context, any `yield` as a pipe body - // is considered simply an identifier. - // This error is checked here, before actually parsing the body expression, - // because `yield`’s “not allowed as identifier in generator” error - // would otherwise have immediately - // occur before the pipe body is fully parsed. - // (Unparenthesized assignment expressions are handled - // in `parseMaybeAssign`, - // and unparenthesized `=>` expressions are handled - // in `checkHackPipeBodyEarlyErrors`.) - const bodyIsInGeneratorContext = this.prodParam.hasYield; - const bodyIsYieldExpression = - bodyIsInGeneratorContext && this.isContextual("yield"); - - if (bodyIsYieldExpression) { - throw this.raise( - this.state.start, - Errors.PipeBodyIsTighter, - this.state.value, + parseHackPipeBody(): N.Expression { + const { start } = this.state; + + const body = this.parseMaybeAssign(); + + // TODO: Check how to handle type casts in Flow and TS once they are supported + if (invalidHackPipeBodies.has(body.type) && !body.extra?.parenthesized) { + this.raise( + start, + Errors.PipeUnparenthesizedBody, + invalidHackPipeBodies.get(body.type), ); - } else { - return this.parseExprOpBaseRightExpr(op, prec); } + if (!this.topicReferenceWasUsedInCurrentContext()) { + // A Hack pipe body must use the topic reference at least once. + this.raise(start, Errors.PipeTopicUnused); + } + + return body; } checkExponentialAfterUnary(node: N.AwaitExpression | N.UnaryExpression) { @@ -2738,24 +2715,7 @@ export default class ExpressionParser extends LValParser { // The `startPos` is the starting position of the pipe body. checkHackPipeBodyEarlyErrors(startPos: number): void { - // If the following token is invalidly `=>`, - // then throw a human-friendly error - // instead of something like 'Unexpected token, expected ";"'. - // For example, `x => x |> y => #` (assuming `#` is the topic reference) - // groups into `x => (x |> y) => #`, - // and `(x |> y) => #` is an invalid arrow function. - // This is because Hack-style `|>` has tighter precedence than `=>`. - // (Unparenthesized `yield` expressions are handled - // in `parseHackPipeBody`, - // and unparenthesized assignment expressions are handled - // in `parseMaybeAssign`.) - if (this.match(tt.arrow)) { - throw this.raise( - this.state.start, - Errors.PipeBodyIsTighter, - tt.arrow.label, - ); - } else if (!this.topicReferenceWasUsedInCurrentContext()) { + if (!this.topicReferenceWasUsedInCurrentContext()) { // A Hack pipe body must use the topic reference at least once. this.raise(startPos, Errors.PipeTopicUnused); } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/options.json index b58a56adfd9d..5d133a4e1801 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/options.json @@ -7,6 +7,5 @@ "topicToken": "#" } ] - ], - "throws": "Unexpected => after pipeline body; any => expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:8)" + ] } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/output.json new file mode 100644 index 000000000000..4078ecbe0a00 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/output.json @@ -0,0 +1,62 @@ +{ + "type": "File", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized arrow function expression; please wrap it in parentheses. (1:6)" + ], + "program": { + "type": "Program", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "left": { + "type": "NumericLiteral", + "start":0,"end":2,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":2}}, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + }, + "operator": "|>", + "right": { + "type": "ArrowFunctionExpression", + "start":6,"end":16,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":16}}, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"x"}, + "name": "x" + } + ], + "body": { + "type": "BinaryExpression", + "start":11,"end":16,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":16}}, + "left": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"x"}, + "name": "x" + }, + "operator": "+", + "right": { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/options.json index 8b17059d1eea..5d133a4e1801 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/options.json @@ -7,6 +7,5 @@ "topicToken": "#" } ] - ], - "throws": "Unexpected &&= after pipeline body; any &&= expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:11)" -} + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/output.json new file mode 100644 index 000000000000..41d7cc567fe5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/output.json @@ -0,0 +1,44 @@ +{ + "type": "File", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}}, + "operator": "&&=", + "left": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/options.json index 44fc8ec43778..5d133a4e1801 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/options.json @@ -7,6 +7,5 @@ "topicToken": "#" } ] - ], - "throws": "Unexpected = after pipeline body; any = expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:16)" -} + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/output.json new file mode 100644 index 000000000000..2d377919e7b2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/output.json @@ -0,0 +1,55 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":9,"end":19,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":19}}, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "elements": [ + { + "type": "Identifier", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, + "name": "x" + }, + { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"y"}, + "name": "y" + } + ] + }, + "right": { + "type": "TopicReference", + "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/options.json index daec111d1135..5d133a4e1801 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/options.json @@ -7,6 +7,5 @@ "topicToken": "#" } ] - ], - "throws": "Unexpected += after pipeline body; any += expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:11)" -} + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/output.json new file mode 100644 index 000000000000..daf345f63a28 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/output.json @@ -0,0 +1,44 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "operator": "+=", + "left": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "TopicReference", + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-associativity/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-associativity/input.js new file mode 100644 index 000000000000..e60721ee6971 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-associativity/input.js @@ -0,0 +1 @@ +1 |> f(#) |> g(#); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-associativity/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-associativity/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-associativity/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-associativity/output.json new file mode 100644 index 000000000000..288c04e15ec5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-associativity/output.json @@ -0,0 +1,66 @@ +{ + "type": "File", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "program": { + "type": "Program", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "left": { + "type": "NumericLiteral", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":5,"end":17,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":17}}, + "left": { + "type": "CallExpression", + "start":5,"end":9,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":9}}, + "callee": { + "type": "Identifier", + "start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"f"}, + "name": "f" + }, + "arguments": [ + { + "type": "TopicReference", + "start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8}} + } + ] + }, + "operator": "|>", + "right": { + "type": "CallExpression", + "start":13,"end":17,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":17}}, + "callee": { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"g"}, + "name": "g" + }, + "arguments": [ + { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + } + ] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/options.json deleted file mode 100644 index 001ba9d36598..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], - "throws": "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (2:14)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json index 4fcf20826e22..ab141137b42f 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json @@ -22,10 +22,6 @@ "right": { "type": "ArrowFunctionExpression", "start":6,"end":32,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":32}}, - "extra": { - "parenthesized": true, - "parenStart": 5 - }, "id": null, "generator": false, "async": false, @@ -40,14 +36,14 @@ "type": "BinaryExpression", "start":11,"end":32,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":32}}, "left": { + "type": "TopicReference", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} + }, + "operator": "|>", + "right": { "type": "BinaryExpression", - "start":11,"end":23,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":23}}, + "start":16,"end":32,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":32}}, "left": { - "type": "TopicReference", - "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} - }, - "operator": "|>", - "right": { "type": "CallExpression", "start":16,"end":23,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":23}}, "callee": { @@ -66,27 +62,31 @@ "name": "$" } ] - } - }, - "operator": "|>", - "right": { - "type": "BinaryExpression", - "start":27,"end":32,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":32}}, - "left": { - "type": "TopicReference", - "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}} }, - "operator": ">", + "operator": "|>", "right": { - "type": "NumericLiteral", - "start":31,"end":32,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":32}}, - "extra": { - "rawValue": 1, - "raw": "1" + "type": "BinaryExpression", + "start":27,"end":32,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":32}}, + "left": { + "type": "TopicReference", + "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}} }, - "value": 1 + "operator": ">", + "right": { + "type": "NumericLiteral", + "start":31,"end":32,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":32}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } } } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json index 2ec88e533289..9d7a5f58fb36 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json @@ -25,10 +25,6 @@ "right": { "type": "ArrowFunctionExpression", "start":6,"end":17,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":17}}, - "extra": { - "parenthesized": true, - "parenStart": 5 - }, "id": null, "generator": false, "async": false, @@ -52,6 +48,10 @@ "type": "TopicReference", "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}} } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-outer-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-outer-topic/output.json index 8223c338ae78..cfab816d1276 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-outer-topic/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-outer-topic/output.json @@ -26,10 +26,6 @@ "right": { "type": "BinaryExpression", "start":6,"end":12,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":12}}, - "extra": { - "parenthesized": true, - "parenStart": 5 - }, "left": { "type": "Identifier", "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"$"}, @@ -40,6 +36,10 @@ "type": "Identifier", "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, "name": "f" + }, + "extra": { + "parenthesized": true, + "parenStart": 5 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-parenthesized/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-parenthesized/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-parenthesized/options.json new file mode 100644 index 000000000000..be2b04c70d33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-parenthesized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-parenthesized/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-parenthesized/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-unparenthesized/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-unparenthesized/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-unparenthesized/options.json new file mode 100644 index 000000000000..5d133a4e1801 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-unparenthesized/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "#" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-unparenthesized/output.json new file mode 100644 index 000000000000..3bcb52365757 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-generator-unparenthesized/output.json @@ -0,0 +1,64 @@ +{ + "type": "File", + "start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized yield expression; please wrap it in parentheses. (2:14)" + ], + "program": { + "type": "Program", + "start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "id": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, + "name": "f" + }, + "generator": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"x"}, + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "start":17,"end":43,"loc":{"start":{"line":1,"column":17},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ReturnStatement", + "start":21,"end":41,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":22}}, + "argument": { + "type": "BinaryExpression", + "start":28,"end":40,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":21}}, + "left": { + "type": "Identifier", + "start":28,"end":29,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "YieldExpression", + "start":33,"end":40,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":21}}, + "delegate": false, + "argument": { + "type": "TopicReference", + "start":39,"end":40,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":21}} + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-identifier-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-identifier-unparenthesized/input.js new file mode 100644 index 000000000000..3d85a40bae18 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-identifier-unparenthesized/input.js @@ -0,0 +1 @@ +x |> yield + #; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-identifier-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-identifier-unparenthesized/options.json new file mode 100644 index 000000000000..5d133a4e1801 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-identifier-unparenthesized/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "#" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-identifier-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-identifier-unparenthesized/output.json new file mode 100644 index 000000000000..cdd141011b5e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-yield-identifier-unparenthesized/output.json @@ -0,0 +1,41 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":5,"end":14,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":5,"end":10,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":10},"identifierName":"yield"}, + "name": "yield" + }, + "operator": "+", + "right": { + "type": "TopicReference", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/options.json index d96fd5fb58f9..bec5b124a302 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/options.json @@ -7,6 +7,5 @@ "topicToken": "%" } ] - ], - "throws": "Unexpected => after pipeline body; any => expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:8)" + ] } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/output.json new file mode 100644 index 000000000000..4078ecbe0a00 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/output.json @@ -0,0 +1,62 @@ +{ + "type": "File", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized arrow function expression; please wrap it in parentheses. (1:6)" + ], + "program": { + "type": "Program", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "left": { + "type": "NumericLiteral", + "start":0,"end":2,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":2}}, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + }, + "operator": "|>", + "right": { + "type": "ArrowFunctionExpression", + "start":6,"end":16,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":16}}, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"x"}, + "name": "x" + } + ], + "body": { + "type": "BinaryExpression", + "start":11,"end":16,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":16}}, + "left": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"x"}, + "name": "x" + }, + "operator": "+", + "right": { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/options.json index 9b71dd195ed7..bec5b124a302 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/options.json @@ -7,6 +7,5 @@ "topicToken": "%" } ] - ], - "throws": "Unexpected &&= after pipeline body; any &&= expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:11)" -} + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/output.json new file mode 100644 index 000000000000..41d7cc567fe5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/output.json @@ -0,0 +1,44 @@ +{ + "type": "File", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}}, + "operator": "&&=", + "left": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/options.json index 363e504916df..bec5b124a302 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/options.json @@ -7,6 +7,5 @@ "topicToken": "%" } ] - ], - "throws": "Unexpected = after pipeline body; any = expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:16)" -} + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/output.json new file mode 100644 index 000000000000..2d377919e7b2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/output.json @@ -0,0 +1,55 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":9,"end":19,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":19}}, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "elements": [ + { + "type": "Identifier", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, + "name": "x" + }, + { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"y"}, + "name": "y" + } + ] + }, + "right": { + "type": "TopicReference", + "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/options.json index 624a1edca22a..bec5b124a302 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/options.json @@ -7,6 +7,5 @@ "topicToken": "%" } ] - ], - "throws": "Unexpected += after pipeline body; any += expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:11)" -} + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/output.json new file mode 100644 index 000000000000..daf345f63a28 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/output.json @@ -0,0 +1,44 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "operator": "+=", + "left": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "TopicReference", + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-associativity/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-associativity/input.js new file mode 100644 index 000000000000..02e0cc1d4050 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-associativity/input.js @@ -0,0 +1 @@ +1 |> f(%) |> g(%); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-associativity/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-associativity/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-associativity/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-associativity/output.json new file mode 100644 index 000000000000..288c04e15ec5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-associativity/output.json @@ -0,0 +1,66 @@ +{ + "type": "File", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "program": { + "type": "Program", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "left": { + "type": "NumericLiteral", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":5,"end":17,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":17}}, + "left": { + "type": "CallExpression", + "start":5,"end":9,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":9}}, + "callee": { + "type": "Identifier", + "start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"f"}, + "name": "f" + }, + "arguments": [ + { + "type": "TopicReference", + "start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8}} + } + ] + }, + "operator": "|>", + "right": { + "type": "CallExpression", + "start":13,"end":17,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":17}}, + "callee": { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"g"}, + "name": "g" + }, + "arguments": [ + { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + } + ] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/options.json deleted file mode 100644 index c75a5d4a544f..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]], - "throws": "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (2:14)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json index 4fcf20826e22..ab141137b42f 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json @@ -22,10 +22,6 @@ "right": { "type": "ArrowFunctionExpression", "start":6,"end":32,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":32}}, - "extra": { - "parenthesized": true, - "parenStart": 5 - }, "id": null, "generator": false, "async": false, @@ -40,14 +36,14 @@ "type": "BinaryExpression", "start":11,"end":32,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":32}}, "left": { + "type": "TopicReference", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} + }, + "operator": "|>", + "right": { "type": "BinaryExpression", - "start":11,"end":23,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":23}}, + "start":16,"end":32,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":32}}, "left": { - "type": "TopicReference", - "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} - }, - "operator": "|>", - "right": { "type": "CallExpression", "start":16,"end":23,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":23}}, "callee": { @@ -66,27 +62,31 @@ "name": "$" } ] - } - }, - "operator": "|>", - "right": { - "type": "BinaryExpression", - "start":27,"end":32,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":32}}, - "left": { - "type": "TopicReference", - "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}} }, - "operator": ">", + "operator": "|>", "right": { - "type": "NumericLiteral", - "start":31,"end":32,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":32}}, - "extra": { - "rawValue": 1, - "raw": "1" + "type": "BinaryExpression", + "start":27,"end":32,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":32}}, + "left": { + "type": "TopicReference", + "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}} }, - "value": 1 + "operator": ">", + "right": { + "type": "NumericLiteral", + "start":31,"end":32,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":32}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } } } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json index 2ec88e533289..9d7a5f58fb36 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json @@ -25,10 +25,6 @@ "right": { "type": "ArrowFunctionExpression", "start":6,"end":17,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":17}}, - "extra": { - "parenthesized": true, - "parenStart": 5 - }, "id": null, "generator": false, "async": false, @@ -52,6 +48,10 @@ "type": "TopicReference", "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}} } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/output.json index 8223c338ae78..cfab816d1276 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/output.json @@ -26,10 +26,6 @@ "right": { "type": "BinaryExpression", "start":6,"end":12,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":12}}, - "extra": { - "parenthesized": true, - "parenStart": 5 - }, "left": { "type": "Identifier", "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"$"}, @@ -40,6 +36,10 @@ "type": "Identifier", "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, "name": "f" + }, + "extra": { + "parenthesized": true, + "parenStart": 5 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-parenthesized/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-parenthesized/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-parenthesized/options.json new file mode 100644 index 000000000000..cfbb79338626 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-parenthesized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-parenthesized/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-parenthesized/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-unparenthesized/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-unparenthesized/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-unparenthesized/options.json new file mode 100644 index 000000000000..bec5b124a302 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-unparenthesized/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "%" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-unparenthesized/output.json new file mode 100644 index 000000000000..3bcb52365757 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-generator-unparenthesized/output.json @@ -0,0 +1,64 @@ +{ + "type": "File", + "start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized yield expression; please wrap it in parentheses. (2:14)" + ], + "program": { + "type": "Program", + "start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "id": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, + "name": "f" + }, + "generator": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"x"}, + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "start":17,"end":43,"loc":{"start":{"line":1,"column":17},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ReturnStatement", + "start":21,"end":41,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":22}}, + "argument": { + "type": "BinaryExpression", + "start":28,"end":40,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":21}}, + "left": { + "type": "Identifier", + "start":28,"end":29,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "YieldExpression", + "start":33,"end":40,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":21}}, + "delegate": false, + "argument": { + "type": "TopicReference", + "start":39,"end":40,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":21}} + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-identifier-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-identifier-unparenthesized/input.js new file mode 100644 index 000000000000..736fab70cfbd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-identifier-unparenthesized/input.js @@ -0,0 +1 @@ +x |> yield + %; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-identifier-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-identifier-unparenthesized/options.json new file mode 100644 index 000000000000..ff2224a90568 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-identifier-unparenthesized/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "%" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-identifier-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-identifier-unparenthesized/output.json new file mode 100644 index 000000000000..cdd141011b5e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-yield-identifier-unparenthesized/output.json @@ -0,0 +1,41 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":5,"end":14,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":5,"end":10,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":10},"identifierName":"yield"}, + "name": "yield" + }, + "operator": "+", + "right": { + "type": "TopicReference", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-addition/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-addition/output.js index 73bb5a695bf4..62a22e6b7067 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-addition/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-addition/output.js @@ -1,4 +1,4 @@ var _ref, _ref2; -const result = (_ref2 = (_ref = 5, _ref + 1), _ref2 + _ref2); +const result = (_ref2 = 5, (_ref = _ref2 + 1, _ref + _ref)); expect(result).toBe(12); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function-and-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function-and-nested-pipe/output.js index 01bf3aa32c0c..bf1fcd321aef 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function-and-nested-pipe/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function-and-nested-pipe/output.js @@ -1,8 +1,8 @@ -var _ref, _ref5, _ref6; +var _ref4, _ref5, _ref6; -const result = (_ref6 = (_ref5 = (_ref = 5, Math.pow(_ref, 2)), [1, 2, 3].map(n => { - var _ref2, _ref3, _ref4; +const result = (_ref6 = 5, (_ref5 = Math.pow(_ref6, 2), (_ref4 = [1, 2, 3].map(n => { + var _ref, _ref2, _ref3; - return _ref4 = (_ref3 = (_ref2 = n + _ref5, _ref2 * 2), `${_ref3} apples`), _ref4.toUpperCase(); -})), _ref6.join()); + return _ref3 = n + _ref5, (_ref2 = _ref3 * 2, (_ref = `${_ref2} apples`, _ref.toUpperCase())); +}), _ref4.join()))); expect(result).toEqual('52 APPLES,54 APPLES,56 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/output.js index 08ae200f6e6d..fb4695950f6c 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/output.js @@ -1,8 +1,7 @@ var _ref, _ref2, _ref3; -const result = (_ref3 = (_ref2 = (_ref = -2.2 // -2.2 -, Math.floor(_ref) // -3 -), () => Math.pow(_ref2, 5) // () => -243 -), _ref3()); // -243 +const result = (_ref3 = -2.2 // -2.2 +, (_ref2 = Math.floor(_ref3) // -3 +, (_ref = () => Math.pow(_ref2, 5), _ref()))); // -243 expect(result).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/output.js index 133f8dbab29d..aa3d4e62d419 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/output.js @@ -5,7 +5,7 @@ function triple(x) { async function asyncFunction(n) { var _ref, _ref2, _ref3; - return _ref3 = (_ref2 = (_ref = n, Math.abs(_ref)), await Promise.resolve(_ref2)), triple(_ref3); + return _ref3 = n, (_ref2 = Math.abs(_ref3), (_ref = await Promise.resolve(_ref2), triple(_ref))); } asyncFunction(-7).then(result => { diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-class-expression-and-private-properties/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-class-expression-and-private-properties/output.js index dcb947391ce7..638f9cda750f 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-class-expression-and-private-properties/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-class-expression-and-private-properties/output.js @@ -1,10 +1,10 @@ var _ref, _ref2, _ref3; -const result = (_ref3 = (_ref2 = (_ref = 1, class { +const result = (_ref3 = 1, (_ref2 = class { #baz; constructor() { - this.#baz = _ref; + this.#baz = _ref3; } #bar() { @@ -15,5 +15,5 @@ const result = (_ref3 = (_ref2 = (_ref = 1, class { return this.#bar() + 3; } -}), new _ref2()), _ref3.foo()); +}, (_ref = new _ref2(), _ref.foo()))); expect(result).toBe(1 + 2 + 3); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-nested-pipe/output.js index 482706ff44ec..8ee6b4bbf42f 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-nested-pipe/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-nested-pipe/output.js @@ -1,4 +1,4 @@ var _ref, _ref2, _ref3, _ref4; -const result = (_ref4 = (_ref = 5, Math.pow(_ref, 2)), (_ref3 = (_ref2 = _ref4 + 1, `${_ref2} apples`), _ref3.toUpperCase())); +const result = (_ref4 = 5, (_ref3 = Math.pow(_ref4, 2), (_ref2 = _ref3 + 1, (_ref = `${_ref2} apples`, _ref.toUpperCase())))); expect(result).toEqual('26 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-object-literal/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-object-literal/output.js index 397577ac5a86..cd74f2422e0a 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-object-literal/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-object-literal/output.js @@ -4,8 +4,8 @@ function area(rect) { return rect.width * rect.height; } -const result = (_ref3 = (_ref2 = (_ref = -5, Math.abs(_ref)), { +const result = (_ref3 = -5, (_ref2 = Math.abs(_ref3), (_ref = { width: _ref2, height: _ref2 + 3 -}), area(_ref3)); +}, area(_ref)))); expect(result).toBe(40); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/output.js index 6323364b3f9e..40f127c27ae2 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/output.js @@ -1,7 +1,7 @@ function* myGenerator(n) { var _ref, _ref2; - return _ref2 = (_ref = n, yield _ref), Math.abs(_ref2); + return _ref2 = n, (_ref = yield _ref2, Math.abs(_ref)); } const myIterator = myGenerator(15); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/output.js index 573e312f0ff5..99d111d1d55e 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/output.js @@ -1,10 +1,9 @@ const result = () => { var _ref, _ref2, _ref3; - return _ref3 = (_ref2 = (_ref = -2.2 // -2.2 - , Math.floor(_ref) // -3 - ), () => Math.pow(_ref2, 5) // () => -243 - ), _ref3(); + return _ref3 = -2.2 // -2.2 + , (_ref2 = Math.floor(_ref3) // -3 + , (_ref = () => Math.pow(_ref2, 5), _ref())); }; // -243 diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-arrow-functions/output.js index 556ae36b837c..23cdd3fe2a2b 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-arrow-functions/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-arrow-functions/output.js @@ -4,5 +4,5 @@ const triple = function (x) { return x * 3; }; -const result = (_ref2 = (_ref = -7, Math.abs(_ref)), triple(_ref2)); +const result = (_ref2 = -7, (_ref = Math.abs(_ref2), triple(_ref))); return expect(result).toBe(21); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-await-and-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-await-and-arrow-functions/output.js index f7bf29a5fad8..3a32f6e23831 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-await-and-arrow-functions/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-await-and-arrow-functions/output.js @@ -5,7 +5,7 @@ const triple = function (x) { async function myFunction(n) { var _ref, _ref2, _ref3, _ref4; - return _ref4 = (_ref3 = (_ref2 = (_ref = n, Math.abs(_ref)), Promise.resolve(_ref2)), await _ref3), triple(_ref4); + return _ref4 = n, (_ref3 = Math.abs(_ref4), (_ref2 = Promise.resolve(_ref3), (_ref = await _ref2, triple(_ref)))); } return myFunction(-7).then(function (result) { diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/while-statement-with-pipe-in-condition/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/while-statement-with-pipe-in-condition/output.js index c249ee76731d..0622dfee4902 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/while-statement-with-pipe-in-condition/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/while-statement-with-pipe-in-condition/output.js @@ -1,7 +1,7 @@ let i = 0; let sum = 0; -while (_ref2 = (_ref = i, i = _ref + 1), _ref2 <= 10) { +while (_ref2 = i, (_ref = i = _ref2 + 1, _ref <= 10)) { var _ref, _ref2; sum += i; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-generator-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-generator-with-yield/output.js index 396c84ad9fff..4e9cfe3a1240 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-generator-with-yield/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-generator-with-yield/output.js @@ -1,5 +1,5 @@ function* myGenerator(n) { var _ref, _ref2; - return _ref2 = (_ref = n, yield _ref), Math.abs(_ref2); + return _ref2 = n, (_ref = yield _ref2, Math.abs(_ref)); } diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-if-else-block/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-if-else-block/output.js index 6782b466aea3..5d542dc97ffc 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-if-else-block/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-if-else-block/output.js @@ -1,3 +1,3 @@ var _ref, _ref2, _ref3, _ref4; -if (_ref2 = (_ref = v, e(_ref)), f(_ref2)) _ref4 = (_ref3 = g(), h(_ref3, _ref3 + 1)), i(_ref4);else j(); +if (_ref2 = v, (_ref = e(_ref2), f(_ref))) _ref4 = g(), (_ref3 = h(_ref4, _ref4 + 1), i(_ref3));else j(); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/output.js index 73bb5a695bf4..62a22e6b7067 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/output.js @@ -1,4 +1,4 @@ var _ref, _ref2; -const result = (_ref2 = (_ref = 5, _ref + 1), _ref2 + _ref2); +const result = (_ref2 = 5, (_ref = _ref2 + 1, _ref + _ref)); expect(result).toBe(12); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/output.js index 01bf3aa32c0c..bf1fcd321aef 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/output.js @@ -1,8 +1,8 @@ -var _ref, _ref5, _ref6; +var _ref4, _ref5, _ref6; -const result = (_ref6 = (_ref5 = (_ref = 5, Math.pow(_ref, 2)), [1, 2, 3].map(n => { - var _ref2, _ref3, _ref4; +const result = (_ref6 = 5, (_ref5 = Math.pow(_ref6, 2), (_ref4 = [1, 2, 3].map(n => { + var _ref, _ref2, _ref3; - return _ref4 = (_ref3 = (_ref2 = n + _ref5, _ref2 * 2), `${_ref3} apples`), _ref4.toUpperCase(); -})), _ref6.join()); + return _ref3 = n + _ref5, (_ref2 = _ref3 * 2, (_ref = `${_ref2} apples`, _ref.toUpperCase())); +}), _ref4.join()))); expect(result).toEqual('52 APPLES,54 APPLES,56 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js index 08ae200f6e6d..fb4695950f6c 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js @@ -1,8 +1,7 @@ var _ref, _ref2, _ref3; -const result = (_ref3 = (_ref2 = (_ref = -2.2 // -2.2 -, Math.floor(_ref) // -3 -), () => Math.pow(_ref2, 5) // () => -243 -), _ref3()); // -243 +const result = (_ref3 = -2.2 // -2.2 +, (_ref2 = Math.floor(_ref3) // -3 +, (_ref = () => Math.pow(_ref2, 5), _ref()))); // -243 expect(result).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/output.js index 133f8dbab29d..aa3d4e62d419 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/output.js @@ -5,7 +5,7 @@ function triple(x) { async function asyncFunction(n) { var _ref, _ref2, _ref3; - return _ref3 = (_ref2 = (_ref = n, Math.abs(_ref)), await Promise.resolve(_ref2)), triple(_ref3); + return _ref3 = n, (_ref2 = Math.abs(_ref3), (_ref = await Promise.resolve(_ref2), triple(_ref))); } asyncFunction(-7).then(result => { diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/output.js index dcb947391ce7..638f9cda750f 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/output.js @@ -1,10 +1,10 @@ var _ref, _ref2, _ref3; -const result = (_ref3 = (_ref2 = (_ref = 1, class { +const result = (_ref3 = 1, (_ref2 = class { #baz; constructor() { - this.#baz = _ref; + this.#baz = _ref3; } #bar() { @@ -15,5 +15,5 @@ const result = (_ref3 = (_ref2 = (_ref = 1, class { return this.#bar() + 3; } -}), new _ref2()), _ref3.foo()); +}, (_ref = new _ref2(), _ref.foo()))); expect(result).toBe(1 + 2 + 3); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/output.js index 482706ff44ec..8ee6b4bbf42f 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/output.js @@ -1,4 +1,4 @@ var _ref, _ref2, _ref3, _ref4; -const result = (_ref4 = (_ref = 5, Math.pow(_ref, 2)), (_ref3 = (_ref2 = _ref4 + 1, `${_ref2} apples`), _ref3.toUpperCase())); +const result = (_ref4 = 5, (_ref3 = Math.pow(_ref4, 2), (_ref2 = _ref3 + 1, (_ref = `${_ref2} apples`, _ref.toUpperCase())))); expect(result).toEqual('26 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/output.js index 397577ac5a86..cd74f2422e0a 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/output.js @@ -4,8 +4,8 @@ function area(rect) { return rect.width * rect.height; } -const result = (_ref3 = (_ref2 = (_ref = -5, Math.abs(_ref)), { +const result = (_ref3 = -5, (_ref2 = Math.abs(_ref3), (_ref = { width: _ref2, height: _ref2 + 3 -}), area(_ref3)); +}, area(_ref)))); expect(result).toBe(40); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/output.js index 6323364b3f9e..40f127c27ae2 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/output.js @@ -1,7 +1,7 @@ function* myGenerator(n) { var _ref, _ref2; - return _ref2 = (_ref = n, yield _ref), Math.abs(_ref2); + return _ref2 = n, (_ref = yield _ref2, Math.abs(_ref)); } const myIterator = myGenerator(15); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js index 573e312f0ff5..99d111d1d55e 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js @@ -1,10 +1,9 @@ const result = () => { var _ref, _ref2, _ref3; - return _ref3 = (_ref2 = (_ref = -2.2 // -2.2 - , Math.floor(_ref) // -3 - ), () => Math.pow(_ref2, 5) // () => -243 - ), _ref3(); + return _ref3 = -2.2 // -2.2 + , (_ref2 = Math.floor(_ref3) // -3 + , (_ref = () => Math.pow(_ref2, 5), _ref())); }; // -243 diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/output.js index 556ae36b837c..23cdd3fe2a2b 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/output.js @@ -4,5 +4,5 @@ const triple = function (x) { return x * 3; }; -const result = (_ref2 = (_ref = -7, Math.abs(_ref)), triple(_ref2)); +const result = (_ref2 = -7, (_ref = Math.abs(_ref2), triple(_ref))); return expect(result).toBe(21); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/output.js index f7bf29a5fad8..3a32f6e23831 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/output.js @@ -5,7 +5,7 @@ const triple = function (x) { async function myFunction(n) { var _ref, _ref2, _ref3, _ref4; - return _ref4 = (_ref3 = (_ref2 = (_ref = n, Math.abs(_ref)), Promise.resolve(_ref2)), await _ref3), triple(_ref4); + return _ref4 = n, (_ref3 = Math.abs(_ref4), (_ref2 = Promise.resolve(_ref3), (_ref = await _ref2, triple(_ref)))); } return myFunction(-7).then(function (result) { diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/output.js index c249ee76731d..0622dfee4902 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/output.js @@ -1,7 +1,7 @@ let i = 0; let sum = 0; -while (_ref2 = (_ref = i, i = _ref + 1), _ref2 <= 10) { +while (_ref2 = i, (_ref = i = _ref2 + 1, _ref <= 10)) { var _ref, _ref2; sum += i; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-generator-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-generator-with-yield/output.js index 396c84ad9fff..4e9cfe3a1240 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-generator-with-yield/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-generator-with-yield/output.js @@ -1,5 +1,5 @@ function* myGenerator(n) { var _ref, _ref2; - return _ref2 = (_ref = n, yield _ref), Math.abs(_ref2); + return _ref2 = n, (_ref = yield _ref2, Math.abs(_ref)); } diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-if-else-block/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-if-else-block/output.js index 6782b466aea3..5d542dc97ffc 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-if-else-block/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-if-else-block/output.js @@ -1,3 +1,3 @@ var _ref, _ref2, _ref3, _ref4; -if (_ref2 = (_ref = v, e(_ref)), f(_ref2)) _ref4 = (_ref3 = g(), h(_ref3, _ref3 + 1)), i(_ref4);else j(); +if (_ref2 = v, (_ref = e(_ref2), f(_ref))) _ref4 = g(), (_ref3 = h(_ref4, _ref4 + 1), i(_ref3));else j();