-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:pattern-matchingarea:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement
Description
under -source:future, a refutable pattern in a for comprehension only produces the standard "match may not be exhaustive" error.
Compiler version
3.3.1
Minimized code
import scala.language.future
case class BoxWithFilter[T](t: T):
def map[U](f: T => U): BoxWithFilter[U] = ???
def flatMap[U](f: T => BoxWithFilter[U]): BoxWithFilter[U] = ???
def withFilter(b: T => Boolean): BoxWithFilter[T] = ???
def foo: BoxWithFilter[Int] = for x :: _ <- BoxWithFilter(List(23)) yield xOutput
[warn] ./pattern-bindings.scala:8:35
[warn] match may not be exhaustive.
[warn]
[warn] It would fail on pattern case: Nil
[warn] def foo: BoxWithFilter[Int] = for x :: _ <- BoxWithFilter(List(23)) yield x
[warn] ^Expectation
It would be good to remind the user that they can use case in front of the pattern, which will introduce the call to withFilter
Metadata
Metadata
Assignees
Labels
area:pattern-matchingarea:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement