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

Add migration helpers for named tuples #21681

Open
odersky opened this issue Oct 1, 2024 · 2 comments
Open

Add migration helpers for named tuples #21681

odersky opened this issue Oct 1, 2024 · 2 comments
Labels
area:experimental:named-tuples Issues tied to the named tuples feature. itype:enhancement Spree Suitable for a future Spree

Comments

@odersky
Copy link
Contributor

odersky commented Oct 1, 2024

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
@odersky odersky added stat:needs triage Every issue needs to have an "area" and "itype" label itype:enhancement and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 1, 2024
@odersky
Copy link
Contributor Author

odersky commented Oct 1, 2024

Maybe suitable for the next Spree?

@odersky odersky added the Spree Suitable for a future Spree label Oct 1, 2024
@Gedochao Gedochao added the area:experimental:named-tuples Issues tied to the named tuples feature. label Oct 1, 2024
@som-snytt
Copy link
Contributor

Discussion of infix named args #19072

and #21565 was a quickie deprecation from last month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:experimental:named-tuples Issues tied to the named tuples feature. itype:enhancement Spree Suitable for a future Spree
Projects
None yet
Development

No branches or pull requests

3 participants