Make left hand side of ->
parse as a tuple of arguments
#522
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))) 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 toExpr
in order to keepExpr
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 intoExpr
form.)