Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Parameter untupling does not accommodate varargs #17779

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
som-snytt opened this issue Jan 27, 2022 · 0 comments
Closed

Parameter untupling does not accommodate varargs #17779

som-snytt opened this issue Jan 27, 2022 · 0 comments
Labels
stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.1.0

Minimized code

scala> val xs = List(1->10,2->20)
val xs: List[(Int, Int)] = List((1,10), (2,20))

scala> def f(n: Int*) = n.sum
def f(n: Int*): Int

scala> xs.map(f)
-- Error:
1 |xs.map(f)
  |       ^
  |       Found:    Seq[Int] => Int
  |       Required: ((Int, Int)) => Int

scala> def g(i: Int, j: Int) = i+j
def g(i: Int, j: Int): Int

scala> xs.map(g)
val res0: List[Int] = List(11, 22)

Output

-- Error:

Expectation

Adapt the tuple to my repeated parameter.

Implies #14367

A snag is the spec language that "n > 1". The impedance is def f[A](as: A*) because A can be the arbitrary tuple. But that is fine, it just says the adaptation is not needed.

@som-snytt som-snytt added the stat:needs triage Every issue needs to have an "area" and "itype" label label Jan 27, 2022
@anatoliykmetyuk anatoliykmetyuk transferred this issue from scala/scala3 Jan 31, 2022
@ckipp01 ckipp01 transferred this issue from lampepfl/dotty-feature-requests Jun 5, 2023
@scala scala locked and limited conversation to collaborators Jun 5, 2023
@ckipp01 ckipp01 converted this issue into discussion #17780 Jun 5, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

1 participant