Skip to content
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

Require indent after colon at EOL #16466

Merged
merged 2 commits into from
Dec 5, 2022
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Dec 4, 2022

Require indented definitions after a : at the end of a line where an argument is expected.

Fixes #16452

Require indented definitions after a `:` at the end of a line where
an argument is expected.

Fixes scala#16452
@odersky odersky marked this pull request as ready for review December 4, 2022 18:31
@odersky odersky requested a review from prolativ December 4, 2022 18:32
@prolativ
Copy link
Contributor

prolativ commented Dec 5, 2022

This fixes the case when there's a newline after the colon (both in REPL and when compiling an entire file) but in REPL this doesn't parse well yet if the colon is followed by the name of a parameter and an arrow and then the user presses enter, e.g.

scala> val x = Seq(1, 2, 3).map: a =>
-- Error: ----------------------------------------------------------------------
1 |val x = Seq(1, 2, 3).map: a =>
  |        ^^^^^^^^^^^^^^^^^^^
  |        not a legal formal parameter for a function literal
-- [E018] Syntax Error: --------------------------------------------------------
1 |val x = Seq(1, 2, 3).map: a =>
  |                              ^
  |                              expression expected but eof found
  |
  | longer explanation available when compiling with `-explain`

@prolativ prolativ assigned odersky and unassigned prolativ Dec 5, 2022
@odersky
Copy link
Contributor Author

odersky commented Dec 5, 2022

The REPL problem with => should be fixed now as well.

@odersky odersky assigned prolativ and unassigned odersky Dec 5, 2022
@prolativ prolativ merged commit b0883b5 into scala:main Dec 5, 2022
@prolativ prolativ deleted the fix-16452 branch December 5, 2022 14:44
ckipp01 pushed a commit that referenced this pull request May 12, 2023
Follow-up #16466

with test from #14092

which was sadly ignored.

Co-authored-by: Gagandeep kalra <gagandeepkalra1994@gmail.com>
@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eta-expansion with empty block after fewerBraces colon
3 participants