This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Potential bug in 2.8 20090929 build

5 replies
Bill Venners
Joined: 2008-12-18,
User offline. Last seen 31 weeks 5 days ago.

Hi,

I was trying to build under 2.8 nightly from 20090929, and I'm getting
a problem. I can reproduce it with four lines of code:

class ResultOfNotWordForSeq[E, T <: Seq[E]](left: T, shouldBeTrue: Boolean)

object Fallish {
def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
new ResultOfNotWordForSeq(left, false)
}

The error message is:

Macintosh-65:stForScala2.8g bv$
/usr/artima/scala-2.8.0.r18815-b20090929021132/bin/scalac delme.scala
delme.scala:5: error: inferred type arguments [T,Array[T]] do not
conform to class ResultOfNotWordForSeq's type parameter bounds [E,T <:
Seq[E]]
def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
new ResultOfNotWordForSeq(left, false)
^
one error found

Is this a bug in the compiler or a "fix." I don't see why an [T,
Array[T]] would not be considered an [E, T <: Seq[E]]. Should I file a
ticket? (I haven't tried this with the 2009930 nightly because I was
asked to build under 20090929 so SBT could get everything compiled
under the same nightly.)

Also, is there a workaround I could use in the meantime? If not that
will throw a wrench into the master plan of the SBT folks to coalesce
around 20090929 as a milestone build. I tried various incantations of
isInstanceOf without success.

Thanks.

Bill
----
Bill Venners
Artima, Inc.
http://www.artima.com

Jorge Ortiz
Joined: 2008-12-16,
User offline. Last seen 29 weeks 4 days ago.
Re: Potential bug in 2.8 20090929 build
From the source:

  final class Array[T](_length: Int) { ... }

New Arrays are now truly native Arrays. They are not Seqs anymore.

--j

On Wed, Sep 30, 2009 at 5:02 PM, Bill Venners <bill@artima.com> wrote:
Hi,

I was trying to build under 2.8 nightly from 20090929, and I'm getting
a problem. I can reproduce it with four lines of code:

class ResultOfNotWordForSeq[E, T <: Seq[E]](left: T, shouldBeTrue: Boolean)

object Fallish {
 def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
new ResultOfNotWordForSeq(left, false)
}

The error message is:

Macintosh-65:stForScala2.8g bv$
/usr/artima/scala-2.8.0.r18815-b20090929021132/bin/scalac delme.scala
delme.scala:5: error: inferred type arguments [T,Array[T]] do not
conform to class ResultOfNotWordForSeq's type parameter bounds [E,T <:
Seq[E]]
 def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
new ResultOfNotWordForSeq(left, false)
                                                                     ^
one error found

Is this a bug in the compiler or a "fix." I don't see why an [T,
Array[T]] would not be considered an [E, T <: Seq[E]]. Should I file a
ticket? (I haven't tried this with the 2009930 nightly because I was
asked to build under 20090929 so SBT could get everything compiled
under the same nightly.)

Also, is there a workaround I could use in the meantime? If not that
will throw a wrench into the master plan of the SBT folks to coalesce
around 20090929 as a milestone build. I tried various incantations of
isInstanceOf without success.

Thanks.

Bill
----
Bill Venners
Artima, Inc.
http://www.artima.com

Mark Harrah
Joined: 2008-12-18,
User offline. Last seen 35 weeks 3 days ago.
Re: Potential bug in 2.8 20090929 build

Hi Bill,

Array no longer extends Seq. There is an implicit conversion from Array to
Seq. See http://lampsvn.epfl.ch/trac/scala/ticket/2395.

-Mark

On Wednesday 30 September 2009, Bill Venners wrote:
> Hi,
>
> I was trying to build under 2.8 nightly from 20090929, and I'm getting
> a problem. I can reproduce it with four lines of code:
>
> class ResultOfNotWordForSeq[E, T <: Seq[E]](left: T, shouldBeTrue: Boolean)
>
> object Fallish {
> def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
> new ResultOfNotWordForSeq(left, false)
> }
>
> The error message is:
>
> Macintosh-65:stForScala2.8g bv$
> /usr/artima/scala-2.8.0.r18815-b20090929021132/bin/scalac delme.scala
> delme.scala:5: error: inferred type arguments [T,Array[T]] do not
> conform to class ResultOfNotWordForSeq's type parameter bounds [E,T <:
> Seq[E]]
> def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
> new ResultOfNotWordForSeq(left, false)
> ^
> one error found
>
> Is this a bug in the compiler or a "fix." I don't see why an [T,
> Array[T]] would not be considered an [E, T <: Seq[E]]. Should I file a
> ticket? (I haven't tried this with the 2009930 nightly because I was
> asked to build under 20090929 so SBT could get everything compiled
> under the same nightly.)
>
> Also, is there a workaround I could use in the meantime? If not that
> will throw a wrench into the master plan of the SBT folks to coalesce
> around 20090929 as a milestone build. I tried various incantations of
> isInstanceOf without success.
>
> Thanks.
>
> Bill
> ----
> Bill Venners
> Artima, Inc.
> http://www.artima.com

Bill Venners
Joined: 2008-12-18,
User offline. Last seen 31 weeks 5 days ago.
Re: Potential bug in 2.8 20090929 build

Hi Jorge,

Thanks for the info. That sounds like a big breaking change for
ScalaTest matchers. I won't be able to look at this until next week,
so this knocks ScalaTest users from playing with the latest 2.8 with
ScalaTest for a while.

Bill

On Wed, Sep 30, 2009 at 6:07 PM, Jorge Ortiz wrote:
> From the source:
>
>   final class Array[T](_length: Int) { ... }
>
> New Arrays are now truly native Arrays. They are not Seqs anymore.
>
> --j
>
> On Wed, Sep 30, 2009 at 5:02 PM, Bill Venners wrote:
>>
>> Hi,
>>
>> I was trying to build under 2.8 nightly from 20090929, and I'm getting
>> a problem. I can reproduce it with four lines of code:
>>
>> class ResultOfNotWordForSeq[E, T <: Seq[E]](left: T, shouldBeTrue:
>> Boolean)
>>
>> object Fallish {
>>  def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
>> new ResultOfNotWordForSeq(left, false)
>> }
>>
>> The error message is:
>>
>> Macintosh-65:stForScala2.8g bv$
>> /usr/artima/scala-2.8.0.r18815-b20090929021132/bin/scalac delme.scala
>> delme.scala:5: error: inferred type arguments [T,Array[T]] do not
>> conform to class ResultOfNotWordForSeq's type parameter bounds [E,T <:
>> Seq[E]]
>>  def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
>> new ResultOfNotWordForSeq(left, false)
>>                                                                      ^
>> one error found
>>
>> Is this a bug in the compiler or a "fix." I don't see why an [T,
>> Array[T]] would not be considered an [E, T <: Seq[E]]. Should I file a
>> ticket? (I haven't tried this with the 2009930 nightly because I was
>> asked to build under 20090929 so SBT could get everything compiled
>> under the same nightly.)
>>
>> Also, is there a workaround I could use in the meantime? If not that
>> will throw a wrench into the master plan of the SBT folks to coalesce
>> around 20090929 as a milestone build. I tried various incantations of
>> isInstanceOf without success.
>>
>> Thanks.
>>
>> Bill
>> ----
>> Bill Venners
>> Artima, Inc.
>> http://www.artima.com
>
>

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Potential bug in 2.8 20090929 build

On Thu, Oct 1, 2009 at 2:02 AM, Bill Venners wrote:
> Hi,
>
> I was trying to build under 2.8 nightly from 20090929, and I'm getting
> a problem. I can reproduce it with four lines of code:
>
> class ResultOfNotWordForSeq[E, T <: Seq[E]](left: T, shouldBeTrue: Boolean)
>
> object Fallish {
>  def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
> new ResultOfNotWordForSeq(left, false)
> }
>
> The error message is:
>
> Macintosh-65:stForScala2.8g bv$
> /usr/artima/scala-2.8.0.r18815-b20090929021132/bin/scalac delme.scala
> delme.scala:5: error: inferred type arguments [T,Array[T]] do not
> conform to class ResultOfNotWordForSeq's type parameter bounds [E,T <:
> Seq[E]]
>  def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
> new ResultOfNotWordForSeq(left, false)
>                                                                      ^
> one error found
>
> Is this a bug in the compiler or a "fix." I don't see why an [T,
> Array[T]] would not be considered an [E, T <: Seq[E]]. Should I file a
> ticket? (I haven't tried this with the 2009930 nightly because I was
> asked to build under 20090929 so SBT could get everything compiled
> under the same nightly.)
>
Hi Bill,

As the others have written, arrays are not sequences anymore, they are
just convertible to them via an implicit conversion. I am about
topublish a writeup of what's changed.

> Also, is there a workaround I could use in the meantime? If not that
> will throw a wrench into the master plan of the SBT folks to coalesce
> around 20090929 as a milestone build. I tried various incantations of
> isInstanceOf without success.
>
It looks like you could generalize ResultOfNotWordForSeq to take
a second parameter with a view bound T <% Seq[T] instead of the
current subtype bound T <: Seq[T].

Cheers

Bill Venners
Joined: 2008-12-18,
User offline. Last seen 31 weeks 5 days ago.
Re: Potential bug in 2.8 20090929 build

Hi Martin,

On Wed, Sep 30, 2009 at 10:45 PM, martin odersky wrote:
> On Thu, Oct 1, 2009 at 2:02 AM, Bill Venners wrote:
>> Hi,
>>
>> I was trying to build under 2.8 nightly from 20090929, and I'm getting
>> a problem. I can reproduce it with four lines of code:
>>
>> class ResultOfNotWordForSeq[E, T <: Seq[E]](left: T, shouldBeTrue: Boolean)
>>
>> object Fallish {
>>  def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
>> new ResultOfNotWordForSeq(left, false)
>> }
>>
>> The error message is:
>>
>> Macintosh-65:stForScala2.8g bv$
>> /usr/artima/scala-2.8.0.r18815-b20090929021132/bin/scalac delme.scala
>> delme.scala:5: error: inferred type arguments [T,Array[T]] do not
>> conform to class ResultOfNotWordForSeq's type parameter bounds [E,T <:
>> Seq[E]]
>>  def should[T](left: Array[T]): ResultOfNotWordForSeq[T, Array[T]] =
>> new ResultOfNotWordForSeq(left, false)
>>                                                                      ^
>> one error found
>>
>> Is this a bug in the compiler or a "fix." I don't see why an [T,
>> Array[T]] would not be considered an [E, T <: Seq[E]]. Should I file a
>> ticket? (I haven't tried this with the 2009930 nightly because I was
>> asked to build under 20090929 so SBT could get everything compiled
>> under the same nightly.)
>>
> Hi Bill,
>
> As the others have written, arrays are not sequences anymore, they are
> just convertible to them via an implicit conversion. I am about
> topublish a writeup of what's changed.
>
>> Also, is there a workaround I could use in the meantime? If not that
>> will throw a wrench into the master plan of the SBT folks to coalesce
>> around 20090929 as a milestone build. I tried various incantations of
>> isInstanceOf without success.
>>
> It looks like you could generalize ResultOfNotWordForSeq to take
> a second parameter with a view bound T <% Seq[T] instead of the
> current subtype bound T <: Seq[T].
>
I tried taking this approach as a quick fix, and it does indeed solve
that type error, but creates another one. Solving that the same way
creates another one. Solving that the same way (which is an ugly one,
T <% AnyRef) creates yet another. Solving that creates three more. So
there unfortunately really isn't a quick fix.

What I need to do is simply rework it to treat Arrays specially. It
should be quite straightforward, but I don't have much time until next
week to work on it. I did make a first stab today, and met with a
stack trace. I submitted this ticket about it:

https://lampsvn.epfl.ch/trac/scala/ticket/2425

I get this same stack trace with the last three nightly 2.8 builds,
but the same modification compiles and passes all the tests just fine
under 2.7.5. So ScalaTest 1.0 for 2.8 snapshot is kind of dead in the
water until I can get past this stack trace.

Thanks.

Bill
----
Bill Venners
Artima, Inc.
http://www.artima.com

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland