Open
Description
reproduction steps
Welcome to Scala 2.13.3 (OpenJDK 64-Bit Server VM, Java 15).
Type in expressions for evaluation. Or try :help.
scala 2.13.3> def f(i: Int, j: Int*) = i + j.sum
def f(i: Int, j: Int*): Int
scala 2.13.3> f(List(2, 3, 4): _*)
^
error: no `: _*` annotation allowed here
(such annotations are only allowed in arguments to *-parameters)
scala 2.13.3> f(j = List(2, 3, 4): _*)
^
error: when using named arguments, the vararg parameter has to be specified exactly once
problem
The vararg was specified exactly once.
scala 2.13.3> f(i = 42, j = List(2, 3, 4): _*)
val res2: Int = 51
scala 2.13.3> f(j = List(2, 3, 4): _*, i = 42)
val res3: Int = 51
Oh, were you asking, What would Dotty do?
Starting scala3 REPL...
scala> def f(i: Int, j: Int*) = i + j.sum
def f(i: Int, j: Int*): Int
scala> f(j = List(2, 3, 4): _*, i = 42)
1 |f(j = List(2, 3, 4): _*, i = 42)
| ^
| _* can be used only for last argument
scala> f(List(2, 3, 4): _*)
1 |f(List(2, 3, 4): _*)
| ^^^^^^^^^^^^^^^^^
|Sequence argument type annotation `: _*` cannot be used here: the corresponding parameter has type Int which is not a repeated parameter type
scala> f(j = List(2, 3, 4): _*)
1 |f(j = List(2, 3, 4): _*)
|^^^^^^^^^^^^^^^^^^^^^^^^
|missing argument for parameter i of method f: (i: Int, j: Int*): Int
So Dotty does fumble what they call in the "default args" business a "swap job." However, "missing i" is as desired.
"Missing i" was also Polyphemus's problem.