You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 15, 2023. It is now read-only.
* Treat await as an almost unary opeator.
Making pipe behave like application seems pretty unlikely.
First `->` has deep binary operator behavior, including associating to the left on a->b->c, and mixes in specific ways with other operators. Instead application lives on a different level entirely with no issues of how to treat specially the right-hand-side which is enclosed in parens.
The await operator is essentially a unary operator. After all it takes on argument. It is also treated as such in JS. Some expected behaviours are that `await 2 + await 3` just like `-2 + -3` is expected to mean `(await 2) + (await 3)`.
The issue raised is with pipe: the desired outcome is that `await a->b` is parsed as `await a->b`. However notice that `- a->b` is parsed as `(-a)->b`.
So on one side, one would like to have `await` behave like other unary operators. On the other side one wouldn't.
As a compromise, this PR treats `await` as an almost-unary operator. In the sense that it binds more tightly than any "real" binary operator such as `+` and `**`, but not more than `->` and `.`.
This introduces some lack of uniformity, and requires special-casing parts of parsing and printing.
* cleanup
* Handle binary operator inside await consistently.
* More tests.
* Update CHANGELOG.md
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@
50
50
- Fix issue where the JSX key type is not an optional string https://github.com/rescript-lang/syntax/pull/693
51
51
- Fix issue where the JSX fragment without children build error https://github.com/rescript-lang/syntax/pull/704
52
52
- Fix issue where async as an id cannot be used with application and labelled arguments https://github.com/rescript-lang/syntax/issues/707
53
-
53
+
- Treat await as almost-unary operator weaker than pipe so `await foo->bar` means `await (foo->bar)`https://github.com/rescript-lang/syntax/pull/711
0 commit comments