Description
Compiler version
3.6
Minimized example
From the SIP 58 proposal, which was recently accepted:
There are some source incompatibilities involving named tuples of length one.
First, what was previously classified as an assignment could now be interpreted as a named tuple. Example:
var age: Int
(age = 1)
This was an assignment in parentheses before, and is a named tuple of arity one now. It is however not idiomatic Scala code, since assignments are not usually enclosed in parentheses.
Second, what was a named argument to an infix operator can now be interpreted as a named tuple.
class C:
infix def f(age: Int)
val c: C
then
c f (age = 1)
will now construct a tuple as second operand instead of passing a named parameter.
Expectation
These problems can be detected and diagnosed fairly straightforwardly: When faced with a unary named tuple, try to interpret it as an assignment, and if that succeeds, issue a migration error and suggest a workaround of these kinds:
{age = 1} // ok
c.f(age = 1) // ok