anorm icon indicating copy to clipboard operation
anorm copied to clipboard

Match exhaustivity warning generated by a macro

Open bwbecker opened this issue 1 year ago • 4 comments

Anorm Version (2.5.x / etc)

2.7.0

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

MacOS 14.2.1

Darwin bwbmac.cs.uwaterloo.ca 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

bwbecker@beta-2 ca.uwaterloo % java -version openjdk version "17.0.9" 2023-10-17 OpenJDK Runtime Environment Homebrew (build 17.0.9+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.9+0, mixed mode, sharing)

Library Dependencies

N/A

Expected Behavior

  1. I expect a call to Macro.namedParser to compile without error.

Actual Behavior

The scala3.3.1 compiler generates a match exhaustivity warning:

bwbecker@beta anorm_bug % scala-cli AnormBug.scala 
Compiling project (Scala 3.3.1, JVM (17))
[warn] ./AnormBug.scala:22:39
[warn] match may not be exhaustive.
[warn] 
[warn] It would fail on pattern case: anorm.~(_, _)
[warn]     val parser: RowParser[QueryLog] = Macro.namedParser[QueryLog]
[warn]                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compiled project (Scala 3.3.1, JVM (17))
Hello, world
bwbecker@beta anorm_bug % 

Reproducible Test Case

Put the following in a file, Anormbug.scala and then run it with scala-cli Anormbug.scala

//> using dep     org.playframework.anorm::anorm:2.7.0


import java.time.LocalDateTime
import anorm._

object Main {

  def main(args: Array[String]): Unit = {
    println("Hello, world")
  }

  private case class QueryLog(
      userid: String,
      run_at: LocalDateTime,
      query_id: Int,
      destination: String,
      succeeds: Boolean
  )

  private def getLastLoggedQuery(destination: String): QueryLog = {
    val parser: RowParser[QueryLog] = Macro.namedParser[QueryLog]
    // DB.withConnection { implicit conn =>
    //   SQL"""
    //       SELECT *
    //       FROM _oat.qry_run_log
    //       WHERE destination = ${destination}
    //       ORDER BY run_at DESC
    //       LIMIT 1
    //   """.as(parser.single)
    // }
    QueryLog("userid", LocalDateTime.now(), 10, "screen", true)
  }
}

bwbecker avatar Feb 20 '24 17:02 bwbecker

Probably duplicate of https://github.com/playframework/anorm/issues/568#issuecomment-1667693168

cchantep avatar Feb 20 '24 18:02 cchantep

Any chance we could have a release since it seems to be fixed in snapshot?

jeejeeone avatar Mar 21 '24 07:03 jeejeeone

Look at the previous link please

cchantep avatar Mar 21 '24 13:03 cchantep

Look at the previous link please

Not sure I follow. It's fixed in snapshot but would be nice to not depend on snapshot thus my question any chance for a release :-) Or maybe there is planned a release? Just curious because the last release is from a while back.

jeejeeone avatar Mar 21 '24 13:03 jeejeeone