Skip to content

"match may not be exhaustive" warning for LazyList (but not for List) #12243

@flomebul

Description

@flomebul

reproduction steps

using Scala 2.13.4,

  def diff(one: LazyList[Int], two: LazyList[Int]): LazyList[Int] =
    (one, two) match {
      case (LazyList(), _) => two
      case (_, LazyList()) => one
      case (onh #:: ont, twh #:: twt) =>
        (onh - twh).sign match {
          case -1 => onh #:: diff(ont, two)
          case  1 => twh #:: diff(one, twt)
          case  0 => diff(ont, twt)
        }
    }

problem

Compiling this code result in a warning

ABug.scala:30: warning: match may not be exhaustive.
It would fail on the following input: (_, _)
    (one, two) match {
    ^

While the same code with List replacing LazyList and "::" replacing "#::" compile without error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions