-
Notifications
You must be signed in to change notification settings - Fork 21
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
Subtractable nightmare on array loops in 2.12 #10151
Comments
Imported From: https://issues.scala-lang.org/browse/SI-10151?orig=1 |
@som-snytt said: package badindices
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
case class DirectedGraph[A](a: A)
class Reader {
class CoNLLToken(
val word:String,
val pos:String,
val lemma:String,
val dep:(Int, String), // head, label
val pred:Int,
val frameBits:Array[String]) {
override def toString:String = word + "/" + pos + "/" + dep._1 + "/" + dep._2 + "/" + pred
}
def toDirectedGraph(tokens:Array[CoNLLToken]):DirectedGraph[String] = {
val edges = new mutable.ListBuffer[(Int, Int, String)] // head, modifier, label
val roots = new mutable.HashSet[Int]()
for(modifier <- tokens.indices) {
val head = tokens(modifier).dep._1
if(head >= 0)
edges += new Tuple3(head, modifier, tokens(modifier).dep._2)
else
roots += modifier
}
DirectedGraph[String]("hi")
}
} with the challenging inference
|
@som-snytt said: |
Encountered this one today... pretty awkward. |
Here is another example of how to reproduce (note the example is a bit contrived as we reduced to remove unnecessary logic)
|
#10359 has a nice short reproduction (of what at least seems to be the same issue, investigation would be needed to confirm) |
I'm putting this on the 2.13.0-M4 milestone because I think we should at least check whether any of these reproducers still fail after new collections land. (If they stop failing, it won't mean the real inference issue is fixed, but it will lower the significance of the bug.) |
There are other type inference issues related to F-bounded types (I assume this is the case here) like #3528. The problem is in |
I’ve tried compiling the code of #10151 (comment) in 2.13.x branch and there is no error anymore (note that we have removed |
Can someone suggest a more informative title for this ticket? |
I've created a gist displaying what I believe is the same bug but with a workaround that is slightly different than the samples shown above: Because these are specs2 tests and not some unit loop, the workaround mentioned previously in this ticket wasn't applicable. |
For the title, I like "Subtractable nightmare", especially as it is almost Halloween and I haven't decided on a costume yet, but I'm also partial to the linked ticket "Perfectly reasonable code doesn't compile", which has better jokes in the comments. |
I am constantly having things like:
(note the code is from https://github.com/antonkulaga/processors that I try to port to 2.12.1)
with java array loops in Scala 2.12.1 (same code works well on Scala 2.11.8).
The text was updated successfully, but these errors were encountered: