Skip to content

Compilation fails with SBT when using DenseVector(index) inside for expression and using toSet #65

Open
@tburny

Description

@tburny

Today I ran across a bug during the "specialize" phase of the Scala compiler/sbt.

The following fails to compile (with an assertion error):
def test() = {
val row = DenseVector(1,2,3,4)
for (j <- 0 until row.length if (row(j) > 3)) yield j
}

whereas the following compiles

def test() = {
val row = DenseVector(1,2,3,4)
for (j <- 0 until row.length if (5 > 3)) yield j
}

As you can see, the only difference is that row(j) has been replaced by a concrete value.
This also works:
def test() = {
val row = DenseVector(1,2,3,4)
for (j <- 0 until row.length if (row.valueAt(j) > 3)) yield j
}

I'm using SBT 12.2 with Scala 2.10.1. I also tried with Scala 2.10.0 with no difference.

Stack trace: https://gist.github.com/tburny/5650247
Source: https://github.com/tburny/bayesian-personalized-ranking/blob/8312ce8fe623ab1480b911e93beed96da6b0e0b9/src/main/scala/de/burnynet/BPRModel.scala
in methods usersWhichRatedItemPositive and positiveItemRatingsByUser

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions