You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looks like scala/scala#6190 regressed linting for unused stuff a local val captured in a CBN closure is not seen as used:
class Test {
def timed[T](body: => T) = body
def run(): Boolean = {
val grouped = List(("bla","bla"))
val (_, _) = timed {
for ((kind, paths) <- grouped) {
println("")
}
(1, 2)
}
false
}
}
nok:
➜ Desktop sbt 'set resolvers += "pr-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration"' 'set scalaVersion := "2.12.5-bin-56918e4"' 'set scalacOptions ++= Seq("-Xfatal-warnings", "-Xlint:unused")' compile
[info] Compiling 1 Scala source to /Users/adriaan/Desktop/target/scala-2.12/classes...
[error] /Users/adriaan/Desktop/unused_captured.scala:5: local val grouped in method run is never used
[error] val grouped = List(("bla","bla"))
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 2 s, completed Mar 8, 2018 11:25:25 AM
ok:
➜ Desktop sbt 'set resolvers += "pr-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration"' 'set scalaVersion := "2.12.5-bin-f78f517"' 'set scalacOptions ++= Seq("-Xfatal-warnings", "-Xlint:unused")' compile
[info] Compiling 1 Scala source to /Users/adriaan/Desktop/target/scala-2.12/classes...
[success] Total time: 3 s, completed Mar 8, 2018 11:25:49 AM
The text was updated successfully, but these errors were encountered:
@adriaanm There's also a weird error in which it refuses to create /tmp/Test.class. This is fresh 2.12.x on MacOS.
$ scalac -d /tmp -Xlint oops.scala
oops.scala:3: warning: type parameter T defined in method timed shadows trait T defined in package <empty>. You may want to rename your type parameter, or possibly remove it.
def timed[T](body: => T) = body
^
one warning found
$ skalac -d /tmp -Xlint oops.scala
oops.scala:3: warning: type parameter T defined in method timed shadows trait T defined in package <empty>. You may want to rename your type parameter, or possibly remove it.
def timed[T](body: => T) = body
^
oops.scala:6: warning: local val grouped in method run is never used
val grouped = List(("bla","bla"))
^
error: error writing Test: Can't create directory /tmp; there is an existing (non-directory) file in its path
two warnings found
one error found
adriaanm
changed the title
warn unused regression with local val captured by closure (in for comprehension?)
warn unused regression involving refutability check in for comprehension
Mar 9, 2018
class Test {
def xsUnused = {
val xs: List[Int] = List(0)
for (refute@1 <- xs) {} // xs is reported as unused when it's hidden in a synthetic withFilter call?
}
}
Looks like scala/scala#6190 regressed linting for unused stuff a local val captured in a CBN closure is not seen as used:
nok:
ok:
The text was updated successfully, but these errors were encountered: