-
Notifications
You must be signed in to change notification settings - Fork 38
await / pipe first precedence #686
Comments
Also, (await (server->start))->ignore loses the server->start->ignore |
This use |
My second comment (losing await) is clearly a bug though - shall I put that into a separate issue? |
Yes please |
So, what is the precedence between await and pipe-first? |
What about |
From googling JS: "An AwaitExpression is a UnaryExpression and has the same precedence as delete, void, typeof, +, -, ~, and !, binding stronger than any binary operator." We should check that this is true and conform to that. |
So the real question seems to be about pipe, not about await. |
Exactly. If we can tell |
It seems correct. |
My thinking was that await server->start corresponds to a method call in JS: await server.start(); which is the same as await (server.start()); |
This is a comment about pipe not await. |
"Organically through some trial and error while trying to fix some Reason problems and it still isn't perfect for all use cases" |
Anything specifically about unary operators? And in fact binary operators. |
I didn't look into the parseUnary and parseBinaray in detail yet. But, the precedence of pipe-first is greater than await. Line 100 in d64839e
That means await e1->e2 should be parsed to (await (e1->e2)) if the precedence logic is affected correctly.
|
Today I grab some time to look at the parse await, unary, binary expression.
|
It's a unary operator that behaves like other unary operators ( |
What I’m thinking strange about is the precendence. op1 op2 a op3 b op1, 2, 3 needs to be parsed by the precedence, no matter it is unary or binary. But await is not affected by precedence rule now. It has just parsed expression right next to it. |
If it's parsed differently (with other priority) competed to other unary operators, it's interesting to know. |
Assuming the discussion ends up on: what's the precedence of pipe.
|
Thanks for the clarified reference. |
There's no "precedence rule". The precedences are: whatever the parser gives you. |
It's difficult to answer a question like that. |
Indeed. I think my expression
Good! I'll clean up my thought and leave an issue later. |
If the pipe has the same precedence as the arrow await a->b
// to
(await a)->b https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence |
Hmm, I'm reading the above as |
Basically, if one wants to try to make This is going to interpret Then see what the consequences of the change are. (And the printer needs similar changes). |
I don't really understand the To me I'm currently working on a program that uses Playwright pretty heavily, and probably will have hundreds of lines of On the other hand,
Besides that, I would expect that a keyword has a lower precedence than an operator. Is there an example, where a ReScript keyword has higher precedence than an operator? |
This can be used for testing #711 |
Tested, seems to work fine, except that the printer adds unnecessary parentheses in this case: (await server->start)->ignore -> (await (server->start))->ignore |
is parsed/printed as
I would have expected it to mean
The text was updated successfully, but these errors were encountered: