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
Hack-pipe proposal with %
topic token
#13416
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 974d8fa:
|
@@ -155,7 +155,7 @@ export const types: { [name: string]: TokenType } = { | |||
bitShift: createBinop("<</>>/>>>", 8), | |||
plusMin: new TokenType("+/-", { beforeExpr, binop: 9, prefix, startsExpr }), | |||
// startsExpr: required by v8intrinsic plugin | |||
modulo: new TokenType("%", { beforeExpr, binop: 10, startsExpr }), |
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 by v8intrinsic
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: "%" }
and v8intrinsic
on, x |> %
breaks due toparseExprAtom
always calling parseV8Intrinsic
first, which then calls unexpected
. 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 the v8intrinsic
plugin, but for the normal %
operator.
Could you check if this code is still parsed correctly?
5 % /3/g
We might need to manually manage exprAllowed
for %
instead of relying on beforeExpr
.
Also, we should check if these two things are parsed correctly:
a |> %
function f() {}
a %
function f() {}
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 😅
I just pushed efdac2d, which makes The problem was that activating babel-parser’s This makes the default Ideally, But, barring that, efdac2d adds a new branch to CC: @ljharb |
4e53882
to
efdac2d
Compare
We also need to also add tests for Hack pipes with syntactic placeholders. We might have to face some interesting questions. For example, should Or perhaps we should simply forbid Edit: It looks like, when with
Perhaps the second examples should remain invalid, in order to match the first example’s precedent, and to avoid modifying |
55b337e
to
dc98f4c
Compare
We can start by disallowing the |
We may reenable combining these again if TC39 ends up deciding to use % as a topic token. See babel#13416 (comment).
fa257f5 disables combining |
623df5c
to
2ebdfd5
Compare
We may reenable combining these again if TC39 ends up deciding to use % as a topic token. See babel#13416 (comment).
236ca74
to
fa257f5
Compare
I don't think it conflicts with |
@JLHwung: Yes, it is true that When @nicolo-ribaudo suggested disallowing v8intrinsic unless TC39 commits to Hack pipes with |
We may reenable combining these again if TC39 ends up deciding to use % as a topic token. See babel#13416 (comment).
I have rebased on I think it can be a good start for reviewing the real diff. The are some parser testing errors from outdated test fixtures, likely due to #13426. I haven't updated the test fixtures. |
@js-choi We squash merge PRs so if your PR depends on the unsquashed branch, GitHub will show all the different commits (87) instead of real different commits (20). The rebased history is more focused because it does not include a merge commit. |
91d28f9
to
c9eb8dd
Compare
I have squashed, rebased onto #13413, and force pushed. |
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
I'm merging this with my and @fedeci's reviews: even if @fedeci's check is not green, he has quite a bit of experience in If there needs to be other changes, this PR is not yet on |
%
topic token
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
This is a continuation of #13191, which added support for
{ proposal: "hack", topicToken: "#" }
to theproposal-pipeline-operator
plugin. This pull request adds support for configuringproposal-pipeline-operator
withtopicToken: "%"
instead of"#"
. See also js-choi/proposal-hack-pipes, tc39/proposal-pipeline-operator#91, and tc39/proposal-hack-pipes#2.