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
-Ywarn-unused warns for vals in for comprehension,"local val... is never used" #9158
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9158?orig=1 |
@som-snytt said: The warning is not spurious, in that the for comprehension desugars into an extra packaging step; it's the for comprehension equivalent of autoboxing. See the part where he goes, "Wait, really?" The locals in the yield block are unused. Intended: for {
tup <- optTup
} yield {
val (num1, num2) = tup
(num1 + num2)
} |
Andrey Kuznetsov (prettynatty) said (edited on Feb 18, 2015 9:55:45 PM UTC): for {
tup1 <- optTup
(num1, num2) = tup1
tup2 <- fn(num2, num1)
} yield {
tup2 // or anything else
} Is it really unintended? |
@som-snytt said: Because the unused extraction result scala> for (s <- List("ab","abc") ; X(i) = s if i > 2) yield i // show
[snip]
val res0 = List("ab", "abc").map(((s) => {
<synthetic> <artifact> private[this] val x$2 = s: @scala.unchecked match {
case (x$1 @ X((i @ _))) => scala.Tuple2(x$1, i)
};
val x$1 = x$2._1;
val i = x$2._2;
scala.Tuple2(s, x$1)
})).withFilter(((x$3) => x$3: @scala.unchecked match {
case scala.Tuple2((s @ _), X((i @ _))) => i > 2
})).map(((x$4) => x$4: @scala.unchecked match {
case scala.Tuple2((s @ _), X((i @ _))) => i
}))
}
}
} |
@som-snytt said: |
The text was updated successfully, but these errors were encountered: