-
-
Notifications
You must be signed in to change notification settings - Fork 45
Make left hand side of -> parse as a tuple of arguments
#522
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
Merged
Conversation
This file contains hidden or 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 makes argument lists on the left hand side of `->` parse as tuples. In particular, this fixes a very inconsistent case where the left hand side previously parsed as a `K"block"`; we now have: * `(a;x=1)->b` ==> `(-> (tuple-p a (parameters (= x 1))) b` rather than `(block a (= x 1))` on the left hand side. In addition, the following forms are treated consistently * `a->b` ==> `(-> (tuple a) b)` * `(a)->b` ==> `(-> (tuple-p a) b)` * `(a,)->b` ==> `(-> (tuple-p-, a) b)` The upside of this is that expression processing of `->` syntax should be much easier. There's one aberrant case involving `where` which is particularly difficult and still not dealt with: `(x where T) -> b` does not parse as `(where (tuple x) T)` on the left hand side. However, `where` precedence involving `::` and `->` is already horribly broken and this syntax will always be awful to write unless we make breaking changes. So I'm too tempted to call this a lost cause for now 😬. Compatibility shims for converting the `SyntaxNode` form back to `Expr` in order to keep `Expr` stable are included. (At some point we should consider fixing this and deleting these shims because the new form is so much more consistent and would be reflected neatly into `Expr` form.)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #522 +/- ##
==========================================
+ Coverage 96.18% 96.19% +0.01%
==========================================
Files 13 13
Lines 4032 4071 +39
==========================================
+ Hits 3878 3916 +38
- Misses 154 155 +1 ☔ View full report in Codecov by Sentry. |
Member
|
This caused an error in RBNF.jl, see thautwarm/RBNF.jl#17 for a workaround. I guess this is #535. |
c42f
added a commit
to JuliaLang/julia
that referenced
this pull request
Oct 17, 2025
…ax.jl#522) This makes argument lists on the left hand side of `->` parse as tuples. In particular, this fixes a very inconsistent case where the left hand side previously parsed as a `K"block"`; we now have: * `(a;x=1)->b` ==> `(-> (tuple-p a (parameters (= x 1))) b` rather than `(block a (= x 1))` on the left hand side. In addition, the following forms are treated consistently * `a->b` ==> `(-> (tuple a) b)` * `(a)->b` ==> `(-> (tuple-p a) b)` * `(a,)->b` ==> `(-> (tuple-p-, a) b)` The upside of this is that expression processing of `->` syntax should be much easier. There's one aberrant case involving `where` which is particularly difficult and still not dealt with: `(x where T) -> b` does not parse as `(where (tuple x) T)` on the left hand side. However, `where` precedence involving `::` and `->` is already horribly broken and this syntax will always be awful to write unless we make breaking changes. So I'm too tempted to call this a lost cause for now 😬. Compatibility shims for converting the `SyntaxNode` form back to `Expr` in order to keep `Expr` stable are included. (At some point we should consider fixing this and deleting these shims because the new form is so much more consistent and would be reflected neatly into `Expr` form.)
topolarity
pushed a commit
to JuliaLang/julia
that referenced
this pull request
Nov 14, 2025
…ax.jl#522) This makes argument lists on the left hand side of `->` parse as tuples. In particular, this fixes a very inconsistent case where the left hand side previously parsed as a `K"block"`; we now have: * `(a;x=1)->b` ==> `(-> (tuple-p a (parameters (= x 1))) b` rather than `(block a (= x 1))` on the left hand side. In addition, the following forms are treated consistently * `a->b` ==> `(-> (tuple a) b)` * `(a)->b` ==> `(-> (tuple-p a) b)` * `(a,)->b` ==> `(-> (tuple-p-, a) b)` The upside of this is that expression processing of `->` syntax should be much easier. There's one aberrant case involving `where` which is particularly difficult and still not dealt with: `(x where T) -> b` does not parse as `(where (tuple x) T)` on the left hand side. However, `where` precedence involving `::` and `->` is already horribly broken and this syntax will always be awful to write unless we make breaking changes. So I'm too tempted to call this a lost cause for now 😬. Compatibility shims for converting the `SyntaxNode` form back to `Expr` in order to keep `Expr` stable are included. (At some point we should consider fixing this and deleting these shims because the new form is so much more consistent and would be reflected neatly into `Expr` form.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This makes argument lists on the left hand side of
->parse as tuples. In particular, this fixes a very inconsistent case where the left hand side previously parsed as aK"block"; we now have:(a;x=1)->b==>(-> (tuple-p a (parameters (= x 1))) brather than
(block a (= x 1))on the left hand side.In addition, the following forms are treated consistently
a->b==>(-> (tuple a) b)(a)->b==>(-> (tuple-p a) b)(a,)->b==>(-> (tuple-p-, a) b)The upside of this is that expression processing of
->syntax should be much easier.There's one aberrant case involving
wherewhich is particularly difficult and still not dealt with:(x where T) -> bdoes not parse as(where (tuple x) T)on the left hand side. However,whereprecedence involving::and->is already horribly broken and this syntax will always be awful to write unless we make breaking changes. So I'm too tempted to call this a lost cause for now 😬.Compatibility shims for converting the
SyntaxNodeform back toExprin order to keepExprstable are included. (At some point we should consider fixing this and deleting these shims because the new form is so much more consistent and would be reflected neatly intoExprform.)