-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Warn for named tuples that look like assignments #21823
base: main
Are you sure you want to change the base?
Conversation
Co-Authored-By: Nicolas Stucki <3648029+nicolasstucki@users.noreply.github.com> Co-Authored-By: Oliver Bračevac <bracevac@users.noreply.github.com>
My quick test shows an unexpected error
for the test in |
def f = 42 + (x = 1) -- [E134] Type Error: playground.scala:1:11 ------------------------------------
1 |def f = 42 + (x = 1)
| ^^^^
| None of the overloaded alternatives of method + in class Int with types
| (x: Double): Double
| (x: Float): Float
| (x: Long): Long
| (x: Int): Int
| (x: Char): Int
| (x: Short): Int
| (x: Byte): Int
| (x: String): String
| match arguments ((x : Int)) It is expected to have an error in this case, isn't it? I also get in on We should add a warning to tell the user that |
Also, we found that our naive use of It doesn't work for example for: object Test:
var age: Int = 28
(age = 29) // warn @nicolasstucki suggests that we move our check to |
Co-Authored-By: Nicolas Stucki <3648029+nicolasstucki@users.noreply.github.com> Co-Authored-By: Oliver Bračevac <bracevac@users.noreply.github.com>
@nicolasstucki @bracevac I moved the check to I then tried to type the whole thing as |
I hit this issue in my own code just this morning, during a 3.6.1 upgrade — locating the cause took me a while, so I’m glad to see a warning being added |
This PR adds a warning for named tuples that look like assignment, such as
(x = 1)
.This is the first half to implement #21681. The second will be to add warnings for named arguments to infix method calls (as a separate PR?).
Started during the Spree of October 21st.