-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Deprecate trailing _
to force eta expansion
#18867
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
Comments
Example: def foo(x: Int): Int = x
val f = foo _ |
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 14, 2023
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 15, 2023
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Nov 15, 2023
Can it be done concisely in another way not requiring minting a variable name? |
Do you mean this val f = foo instead of this? val f = x => foo(x) |
I was going to joke that "the underscore has to go somewhere", but explicit trailing underscore also errors. |
We should make up our mind 😄 - the warning is wrong about varargs: Welcome to Scala 3.5.1-RC1-bin-SNAPSHOT-nonbootstrapped-git-952b928 (17.0.9, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> def foo(xs: Int*) = xs.length
def foo(xs: Int*): Int
scala> val bar = foo _
1 warning found
-- Warning: --------------------------------------------------------------------
1 |val bar = foo _
| ^^^^^
| The syntax `<function> _` is no longer supported;
| you can simply leave out the trailing ` _`
val bar: Seq[Int] => Int = Lambda$12572/0x000000e802c9dc10@2173b693
scala> val bar = foo
-- [E178] Type Error: ----------------------------------------------------------
1 |val bar = foo
| ^^^
| missing argument list for method foo
|
| def foo(xs: Int*): Int
|
| longer explanation available when compiling with `-explain`
1 error found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Warn in: 3.4
Error in: TBD
The text was updated successfully, but these errors were encountered: