Skip to content

Eta expansion val f = mymethod (i.e., no applied argument lists) shows spurious error about trailing "_" #11311

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
deanwampler opened this issue Feb 4, 2021 · 3 comments · Fixed by #11314
Milestone

Comments

@deanwampler
Copy link
Contributor

Compiler version

scala 3.0.0-M3

Minimized code

In the REPL, try this:

def cat1(s1: String)(s2: String) = s1 + s2
val fcat1 = cat1

Output

1 |val fcat1 = cat1
  |            ^^^^
  |            The syntax `<function> _` is no longer supported;
  |            you can simply leave out the trailing ` _`

By accident, I noticed you get exactly the same error message if you type def fcat1 = cat1.

Expectation

It accepts the definition of fcat1, as described in the automatic eta expansion docs, https://dotty.epfl.ch/docs/reference/changed-features/eta-expansion.html

@griggt
Copy link
Contributor

griggt commented Feb 4, 2021

Is this only with -source 3.1 ?

odersky added a commit to dotty-staging/dotty that referenced this issue Feb 4, 2021
There was a superfluous `_` added in eta expansion. That was needed in Scala 2,
but is no longer needed in Scala 3.

Fixes scala#11311
@odersky odersky removed the area:repl label Feb 4, 2021
@odersky
Copy link
Contributor

odersky commented Feb 4, 2021

Seems to be only under 3.1

michelou pushed a commit to michelou/scala3 that referenced this issue Feb 5, 2021
There was a superfluous `_` added in eta expansion. That was needed in Scala 2,
but is no longer needed in Scala 3.

Fixes scala#11311
@deanwampler
Copy link
Contributor Author

Yes, I'm using -source 3.1.

@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants