Skip to content
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

Match exhaustivity warning generated by a macro #599

Closed
bwbecker opened this issue Feb 20, 2024 · 4 comments
Closed

Match exhaustivity warning generated by a macro #599

bwbecker opened this issue Feb 20, 2024 · 4 comments

Comments

@bwbecker
Copy link

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)
  }
}
@cchantep
Copy link
Member

Probably duplicate of #568 (comment)

@jeejeeone
Copy link

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

@cchantep
Copy link
Member

Look at the previous link please

@jeejeeone
Copy link

jeejeeone commented Mar 21, 2024

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.

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

No branches or pull requests

3 participants