Skip to content

Improve report of erroneous sequence argument #10063

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 Oct 21, 2020 · 1 comment
Closed

Improve report of erroneous sequence argument #10063

som-snytt opened this issue Oct 21, 2020 · 1 comment

Comments

@som-snytt
Copy link
Contributor

Minimized code

  dotty git:(master) ./bin/scala
Starting scala3 REPL...
scala> List(1, List(2): _*)
val res0: List[Any] = List(1, List(2))

Output

Sometimes the missing error on the sequence argument ascription makes it hard to spot the problem.

scala> import collection.mutable.ListBuffer

scala> val xs = ListBuffer.empty[Int]
val xs: scala.collection.mutable.ListBuffer[Int] = ListBuffer()

scala> xs.+=(1, 2, 3, List(4,5,6) ++ List(7,8,9): _*)
1 |xs.+=(1, 2, 3, List(4,5,6) ++ List(7,8,9): _*)
  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |               Found:    List[Int]
  |               Required: Int

scala> xs.+=(1, 2, List(4,5,6) ++ List(7,8,9): _*)
1 |xs.+=(1, 2, List(4,5,6) ++ List(7,8,9): _*)
  |^^^^^
  |method += in trait Growable is deprecated since 2.13.0: Use `++=` aka `addAll` instead of varargs `+=`; infix operations with an operand of multiple args will be deprecated
val res0: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 4, 5, 6, 7, 8, 9)

Expectation

  dotty git:(master) scala
Welcome to Scala 2.13.3 (OpenJDK 64-Bit Server VM, Java 14.0.2).
Type in expressions for evaluation. Or try :help.

scala> List(1, List(2): _*)
                      ^
       error: no `: _*' annotation allowed here
       (such annotations are only allowed in arguments to *-parameters)

This is a follow-up to #9749 inspired by #10062

@som-snytt
Copy link
Contributor Author

Duplicated by #11419 fixed by #11423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant