Left precedence of pipeline #12
Comments
Yeah, I’m not sure what the best way to tackle this would be. That’s a fundamental difference between the left-hand sides of That AST Explorer behavior is probably due to its using Babel 7.14, before Hack pipes were actually introduced. |
When trying to think about "what's confusing", always also consider the example with the syntax in the middle: a |> % ? b : c |> % + 1 Should it be On the other hand, Fyi, I opened fkling/astexplorer#599 for ASTExplorer. |
After more thought, I think we should require all conditionals to be parenthesized in pipe heads/bodies after all. I’m thinking that the most desirable behavior might be to ban any any other assignment-level operation without parentheses as a pipe head or body. (The other assignment-level operations are In contrast, pipe expressions would be allowed at any place in other assignment-level operations. So I put a table with this behavior in #11 (comment). I plan to edit the explainer and spec soon. |
After 6c458b5, the left side of a
|
Spinning this out of #11:
That ternary example is super confusing, and it's different than how arrows are parsed:
The spec seems to say arrows and pipelines would bind at the same level, so I'd think the ternary example would be
x ? y : (z |> w)
When I load this into AST explorer, I actually get the same results for pipeline and arrow, but maybe that's just because babel hasn't fixed the right-associativity of the operator yet.
/cc @nicolo-ribaudo
The text was updated successfully, but these errors were encountered: