-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:named-tuplesIssues tied to the named tuples feature.Issues tied to the named tuples feature.area:pattern-matchingarea:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcitype:bug
Description
Compiler version
scalaVersion = "3.7.1"
Checked with Scala CLI version: 1.8.4 Scala version (default): 3.7.1
via //> using scala 3.nightly
- the same thing
Minimized code
//> using scala 3.7.1
import NamedTuple.{
Map as MapFields,
From as FieldsFrom
}
type HkdOf[T, F[_]] = MapFields[FieldsFrom[T], F]
trait Hkd[T]:
type Of[F[_]] = HkdOf[T, F]
inline def of[F[_]](v: HkdOf[T, F]) = v
case class User(age: Int, name: String)
object User extends Hkd[User]
def getUser(userQuery: User.Of[Option]): Unit =
val invalidCheck = userQuery match // must warn, that match will fail on 'case (None, _)' or 'case (_, None)'
case (Some(age), Some(name)) => println("both")
// case Tuple2(Some(age), Some(name)) => println("both") // must warn, that match will fail on 'case (None, _)' or 'case (_, None)'
// val validCheckTup = (Some(123), Option(123)) match // here it does warn
// case (Some(a), Some(b)) => ???
// val validCheckNTup = (age = Some(123), name = Option(123)) match // here it does warn as well
// case (Some(a), Some(b)) => ???
@main def main(): Unit = getUser(User.of[Option](age = Some(123), name = None))
Output
[69] Exception in thread "main" scala.MatchError: (Some(123),None) (of class scala.Tuple2) │
[69] at app.Main$package$.getUser(Main.scala:15) │
[69] at app.Main$package$.main(Main.scala:20) │
[69] at app.main.main(Main.scala:20) │
Expectation
Compiler must issue an exhaustive match warning for the first case
Metadata
Metadata
Assignees
Labels
area:named-tuplesIssues tied to the named tuples feature.Issues tied to the named tuples feature.area:pattern-matchingarea:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcitype:bug