Spurious errors when recompiling

45 views
Skip to first unread message

Alexey Romanov

unread,
Apr 1, 2012, 2:42:21 PM4/1/12
to scala-user
This looks like a possible scalac bug, but I'd expect people to have
run into it before if that was the case.

After checking out https://github.com/alexeyr/scala-time, I can
compile it once (using `mvn compile`). However, touching
src/main/scala/org/scala_tools/time/Implicits.scala and running `mvn
compile` again produces 56 errors similar to

[ERROR] F:\MyProgramming\scala-time\src\main\scala\org\scala_tools\time\StaticDateTime.scala:29:
error: value second is not a member of Int
[ERROR] def nextSecond = now + 1.second

For some reason, they don't use the implicits defined in
Implicits.scala, even though they can access it (there is no

object Implicits is not a member of package org.scala_tools.time

error). This can be reproduced with SBT:

sbt clean; sbt compile;
change Implicits.scala enough to produce different classes (e.g. add a
line "object Implicits2 extends Implicits")
sbt compile

But to make things even weirder, SBT produces a competely different
set of 24 errors!

Rampion at Stack Overflow was also able to reproduce it using scalac
directly: http://stackoverflow.com/a/9964884/9204

So, is it a bug? And if so, where: scalac or SBT and scala-maven-plugin?

Yours, Alexey Romanov

Dave

unread,
Apr 1, 2012, 5:56:23 PM4/1/12
to scala-user
I can reproduce this with sbt 0.11.2 (24 errors) and mvn 3.0.2 (56
errors)
The work around is indeed to do a clean after changing a source file

I couldn't reproduce it with scalac or fsc. I could edit the source
file and compile without clean.
So I guess it only happens with a build tool.



On 1 apr, 20:42, Alexey Romanov <alexey.v.roma...@gmail.com> wrote:
> This looks like a possible scalac bug, but I'd expect people to have
> run into it before if that was the case.
>
> After checking outhttps://github.com/alexeyr/scala-time, I can
> compile it once (using `mvn compile`). However, touching
> src/main/scala/org/scala_tools/time/Implicits.scala and running `mvn
> compile` again produces 56 errors similar to
>
> [ERROR] F:\MyProgramming\scala-time\src\main\scala\org\scala_tools\time\StaticDateT­ime.scala:29:

Alexey Romanov

unread,
Apr 2, 2012, 5:58:00 AM4/2/12
to Dave, scala-user
See https://issues.scala-lang.org/browse/SI-5639 for a reproduction with scalac.

Yours, Alexey Romanov

Dave

unread,
Apr 2, 2012, 6:51:20 AM4/2/12
to scala-user
Yes indeed. Now I see it. I don't even have to edit and it is still in
scala-2.10.0-M2.
Looks like the compiler forgets to put the implicits in scope in the
second run.

Strange though that there is an edit needed for scala-time for sbt/mvn
and that direct compilation with scalac/fsc just works. So I think
that the latter bug is slightly different but related.


C:\scala-2.10.0-M2\examples\implicitsbug>scalac *.scala

C:\scala-2.10.0-M2\examples\implicitsbug>scalac *.scala
Bar.scala:6: error: type mismatch;
found : Int(1)
required: pack.age.Baz
def baz : Baz = 1
^
one error found


On 2 apr, 11:58, Alexey Romanov <alexey.v.roma...@gmail.com> wrote:
> Seehttps://issues.scala-lang.org/browse/SI-5639for a reproduction with scalac.
> >> Yours, Alexey Romanov- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

Dave

unread,
Apr 2, 2012, 6:56:15 AM4/2/12
to scala-user
And it seems only a bug for top level imports.

This below works over and over again:

package pack.age

object Quux {
import pack.age.Implicits._
def baz : Baz = 1
}


On 2 apr, 12:51, Dave <dave.mahabiers...@hotmail.com> wrote:
> Yes indeed. Now I see it. I don't even have to edit and it is still in
> scala-2.10.0-M2.
> Looks like the compiler forgets to put the implicits in scope in the
> second run.
>
> Strange though that there is an edit needed for scala-time for sbt/mvn
> and that direct compilation with scalac/fsc just works. So I think
> that the latter bug is slightly different but related.
>
> C:\scala-2.10.0-M2\examples\implicitsbug>scalac *.scala
>
> C:\scala-2.10.0-M2\examples\implicitsbug>scalac *.scala
> Bar.scala:6: error: type mismatch;
>  found   : Int(1)
>  required: pack.age.Baz
>         def baz : Baz   = 1
>                           ^
> one error found
>
> On 2 apr, 11:58, Alexey Romanov <alexey.v.roma...@gmail.com> wrote:
>
>
>
> > Seehttps://issues.scala-lang.org/browse/SI-5639fora reproduction with scalac.
> > - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit oorspronkelijk bericht niet weergeven -

Johannes Rudolph

unread,
Apr 2, 2012, 7:01:27 AM4/2/12
to Dave, scala-user
Would you add this information to the bug tracker as well, perhaps
with a link to the discussions on the mailing list not everyone is
tracking scala-user.

Thanks for creating the isolated test case, this is great.

Johannes

--
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net

Alexey Romanov

unread,
Apr 2, 2012, 8:32:13 AM4/2/12
to Dave, scala-user
I think edit is needed with mvn/sbt only to get them to recompile the
files :) They simply don't compile if they already have up-to-date
class files and if for some reason they choose different files to
recompile after editing that would explain different sets of errors.

Yours, Alexey Romanov

Dave

unread,
Apr 2, 2012, 8:52:54 AM4/2/12
to scala-user
It's only strange that direct compiling of scala-time with scalac and
fsc doesn't have these errors.

C:\Users\Dave\scala-time>c:\scala-2.9.1-1\bin\scalac.bat -classpath "C:
\Users\Dave\.ivy2\cache\org.scala-lang\scala-library\jars\scala-
library-2.9.1-1.jar;C:\Users\Dave\.ivy2\cache\joda-time\joda-time\jars
\joda-time-2.1.jar;C:\Users\Dave\.ivy2\cache\org.joda\joda-convert\jars
\joda-convert-1.2.jar" ./src/main/scala/org/scala_tools/time/*.scala -
d ./target -verbose

compiles without errors over and over again (no matter if I edit or
not)



On 2 apr, 14:32, Alexey Romanov <alexey.v.roma...@gmail.com> wrote:
> I think edit is needed with mvn/sbt only to get them to recompile the
> files :) They simply don't compile if they already have up-to-date
> class files and if for some reason they choose different files to
> recompile after editing that would explain different sets of errors.
>
> Yours, Alexey Romanov
>
>
>
> On Mon, Apr 2, 2012 at 14:51, Dave <dave.mahabiers...@hotmail.com> wrote:
> > Yes indeed. Now I see it. I don't even have to edit and it is still in
> > scala-2.10.0-M2.
> > Looks like the compiler forgets to put the implicits in scope in the
> > second run.
>
> > Strange though that there is an edit needed for scala-time for sbt/mvn
> > and that direct compilation with scalac/fsc just works. So I think
> > that the latter bug is slightly different but related.
>
> > C:\scala-2.10.0-M2\examples\implicitsbug>scalac *.scala
>
> > C:\scala-2.10.0-M2\examples\implicitsbug>scalac *.scala
> > Bar.scala:6: error: type mismatch;
> >  found   : Int(1)
> >  required: pack.age.Baz
> >        def baz : Baz   = 1
> >                          ^
> > one error found
>
> > On 2 apr, 11:58, Alexey Romanov <alexey.v.roma...@gmail.com> wrote:
> >> Seehttps://issues.scala-lang.org/browse/SI-5639fora reproduction with scalac.
> >> - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit oorspronkelijk bericht niet weergeven -

Alexey Romanov

unread,
Apr 2, 2012, 10:37:22 AM4/2/12
to Dave, scala-user
Yes, that does look as if there are slightly different bugs.

Yours, Alexey Romanov

Reply all
Reply to author
Forward
0 new messages