-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Change fewerBraces
to support inline lambdas after :
#15258
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
Closed
Closed
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
Instead of parsing all formal parameters of a lambda as expressions and converting to parameters at the end, we now scan ahead the first time we see a `:` to determine whether the list is followed by `=>` or `?=>`. If that's the case we parse this parameter and all following ones as bindings instead of expressions.
9f61741
to
8f82a28
Compare
fewerBraces
to always require a :
.
Previously the parser accepted `(x: A => B)` as an expression, but only if there were parentheses around it. This was necessary so that we could parse a potential formal parameter of a closure `(x: A => B) => ...` as an expression and then convert to a type. But it is not backed by the grammar. The grammar requires `x: (A => B)` whether in parentheses or not. We now follow the grammar for source versions from 3.2 on.
- Allow lambda arguments on one line # Conflicts: # compiler/src/dotty/tools/dotc/parsing/Parsers.scala # docs/_docs/internals/syntax.md # tests/neg/closure-args.scala # tests/pos/closure-args.scala
# Conflicts: # docs/_docs/reference/experimental/fewer-braces.md
8f82a28
to
82a7b00
Compare
fewerBraces
to always require a :
.fewerBraces
to support inline lambdas after :
The Regarding the |
I think the proximity with type ascription of dependent function types is too close (see also #15273 (comment)). I don’t think there are any benefits in writing: xs.map: x => x + 1 Instead of: xs.map(x => x + 1) |
Closed in favor of #15273 |
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.
So it's
Now also possible:
Based on #15273.
This PR was reworked to show the delta over #15273 needed to support inline lambdas. Before merging it we should decide whether inline lambdas are a good idea.