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

unused local definition warning when defining focus inside a function #1484

Open
jtjeferreira opened this issue Dec 12, 2024 · 1 comment
Open

Comments

@jtjeferreira
Copy link

case class Lecturer(firstName: String, lastName: String, salary: Int)
case class Department(budget: Int, lecturers: List[Lecturer])
case class University(name: String, departments: Map[String, Department])

val uni = University("oxford", Map(
  "Computer Science" -> Department(45, List(
    Lecturer("john"  , "doe", 10),
    Lecturer("robert", "johnson", 16)
  )),
  "History" -> Department(30, List(
    Lecturer("arnold", "stones", 20)
  ))
))

import monocle.Focus
import monocle.syntax.all._

val departmentsWorks = Focus[University](_.departments)
departmentsWorks.at("History").replace(None)(uni)

def foo() = {

  //warning unused local definition
  val departments = Focus[University](_.departments)
  departments.at("History").replace(None)(uni)
}

foo()

Scastie: https://scastie.scala-lang.org/TfVaZDtKSmKGrgQuI7N3Rg

versions:
scala 3.5.2
monocle 3.3.0

@jtjeferreira
Copy link
Author

I think this is a scala compiler issue already reported in scala/scala3#17753

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

1 participant