-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hack-pipe proposal with %
topic token
#13416
Merged
nicolo-ribaudo
merged 2 commits into
babel:feat-7.15.0/hack-pipes
from
js-choi:proposal-hack-pipes-percent
Jul 6, 2021
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...t/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
value |> (# = 1); |
3 changes: 3 additions & 0 deletions
3
...xtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]] | ||
} |
52 changes: 52 additions & 0 deletions
52
...ixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, | ||
"errors": [ | ||
"SyntaxError: Invalid left-hand side in assignment expression. (1:10)" | ||
], | ||
"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": "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":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15}}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 9 | ||
}, | ||
"operator": "=", | ||
"left": { | ||
"type": "TopicReference", | ||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11}} | ||
}, | ||
"right": { | ||
"type": "NumericLiteral", | ||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}}, | ||
"extra": { | ||
"rawValue": 1, | ||
"raw": "1" | ||
}, | ||
"value": 1 | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...er/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
value |> % |
4 changes: 4 additions & 0 deletions
4
...est/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], | ||
"throws": "Invalid topic token %. In order to use % as a topic reference, the pipelineOperator plugin must be configured with { \"proposal\": \"hack\", \"topicToken\": \"%\" }. (1:9)" | ||
} |
1 change: 1 addition & 0 deletions
1
.../fixtures/experimental/pipeline-operator/hack-hash-proposal-placeholder-template/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
%%FUNCTION%%(0, %%VALUE%%); |
7 changes: 7 additions & 0 deletions
7
...tures/experimental/pipeline-operator/hack-hash-proposal-placeholder-template/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"plugins": [ | ||
["pipelineOperator", { "proposal": "hack", "topicToken": "#" }], | ||
"placeholders" | ||
], | ||
"throws": "Cannot combine placeholders plugin and Hack-style pipes." | ||
} |
1 change: 1 addition & 0 deletions
1
...test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-then-digit/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x |> #42; |
12 changes: 12 additions & 0 deletions
12
.../fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-then-digit/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"pipelineOperator", | ||
{ | ||
"proposal": "hack", | ||
"topicToken": "#" | ||
} | ||
] | ||
], | ||
"throws": "Unexpected digit after hash token. (1:5)" | ||
} |
1 change: 1 addition & 0 deletions
1
...rser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-v8intrinsic/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
%GetOptimizationStatus(f); |
7 changes: 7 additions & 0 deletions
7
.../test/fixtures/experimental/pipeline-operator/hack-hash-proposal-v8intrinsic/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"plugins": [ | ||
["pipelineOperator", { "proposal": "hack", "topicToken": "#" }], | ||
"v8intrinsic" | ||
], | ||
"throws": "Cannot combine v8intrinsic plugin and Hack-style pipes." | ||
} |
1 change: 1 addition & 0 deletions
1
...s/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
value |> % + 1 |
3 changes: 3 additions & 0 deletions
3
...perimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] | ||
} |
45 changes: 45 additions & 0 deletions
45
...xperimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, | ||
"expression": { | ||
"type": "BinaryExpression", | ||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, | ||
"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": "BinaryExpression", | ||
"start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, | ||
"left": { | ||
"type": "TopicReference", | ||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} | ||
}, | ||
"operator": "+", | ||
"right": { | ||
"type": "NumericLiteral", | ||
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}}, | ||
"extra": { | ||
"rawValue": 1, | ||
"raw": "1" | ||
}, | ||
"value": 1 | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...es/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
value |> 1 + % |
3 changes: 3 additions & 0 deletions
3
...xperimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
beforeExpr
is required byv8intrinsic
plugin.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a v8intrinsic test case that is broken by this change? The
babel-parser/test/fixtures/v8intrinsic
suite is still succeeding.It does seem that currently, when babel-parser is configured with both
pipelineOperator: { proposal: "hack", topicToken: "%" }
andv8intrinsic
on,x |> %
breaks due toparseExprAtom
always callingparseV8Intrinsic
first, which then callsunexpected
. This seems to be a separate problem, though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
beforeExpr
is not needed for thev8intrinsic
plugin, but for the normal%
operator.Could you check if this code is still parsed correctly?
We might need to manually manage
exprAllowed
for%
instead of relying onbeforeExpr
.Also, we should check if these two things are parsed correctly:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolo-ribaudo: I added tests for those cases in 5d24958. They seem to be still parsing correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh awesome. I'll still try to find an example that breaks it because I'm not 100% convinced yet that
beforeExpr
is completely unnecessary, but if I cannot find it then it's good 😅