Skip to content
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

Non-deterministic errors reported when implicit parameters are involved #4539

Closed
scabug opened this issue May 3, 2011 · 4 comments
Closed

Comments

@scabug
Copy link

scabug commented May 3, 2011

=== What steps will reproduce the problem (please be specific and use wikiformatting)? ===

case class Ev[T](x: T)

object Yupi {
  implicit val strEv: Ev[String] = Ev("str")

  def ohno[T](implicit m: Manifest[T], e: Ev[T]): T = e.x
  def ohyes[T](implicit e: Ev[T], m: Manifest[T]): T = e.x

  val x = ohno
  val y = ohyes

}

=== What is the expected behavior? ===
I'm not sure if this code should compile at all but what I would expect is deterministic result (code compiles or compiler fails with the same sort of problems reported).

=== What do you see instead? ===
Either:

mac-grek:tmp grek$$ scala implicits.scala 
/Users/grek/tmp/implicits.scala:9: error: could not find implicit value for parameter e: this.Ev[T]
  val x = ohno
          ^
one error found

or:

mac-grek:tmp grek$$ scala implicits.scala 
/Users/grek/tmp/implicits.scala:9: error: could not find implicit value for parameter e: this.Ev[Nothing]
  val x = ohno
          ^
/Users/grek/tmp/implicits.scala:10: error: could not find implicit value for parameter e: this.Ev[Nothing]
  val y = ohyes
          ^
two errors found

I couldn't find any way to reliably trigger first or second behaviour. The only thing that seems to be consistent is that scalac tends to 'stick' to one of behaviour for a while so if you want to reproduce it you might want to have one hour between subsequent runs of scalac.

=== Additional information ===
https://groups.google.com/group/scala-user/browse_thread/thread/f83055972c91a514

=== What versions of the following are you using? ===

  • Scala: 2.8.0, 2.8.1., 2.9.0.RC2 (all three behave in the same way)
  • Java: build 1.6.0_24-b07-334-10M3326, 64bit
  • Operating system: MacOs 10.6.7
@scabug
Copy link
Author

scabug commented May 3, 2011

@scabug
Copy link
Author

scabug commented May 4, 2011

@adriaanm said:
As far as I know there is no random number generator in the compiler, so there must be some deterministic way of triggering this. We just don't know what it is yet. I bet something was different in the environment between those two runs.

Maybe it's caches filling up, or other limits being reached, but I find it hard to believe it's just a matter of using the compiler daemon at certain time intervals. Are you sure your classpath was the same (with the same contents) everytime? Maybe you had some stale classfiles laying around? Can you try with fsc as well (I sure hope this can't be reproduced with scalac!).

There must be a deterministic way to trigger both results; lacking that, I'm afraid it's going to be nearly impossible to fix. (I did try to repro, will try again in an hour...)

@scabug
Copy link
Author

scabug commented May 6, 2011

@gkossakowski said:
Hi Adriaan,

I fully understand that there's no chance to fix this (potential) bug until it can be reproduced reliably. Actually, what's odd started to get the same results for all runs of scalac for all versions. I always get two errors demonstrated above. What about you? Are you getting two errors, two?

Discussion on mailing list with Johannes suggests that he was getting one error for my code too so there's some independent confirmation.

Anyway, I'll try to spend a little bit more time on this on a weekend and see if I can provide some more details.

@scabug scabug closed this as completed May 18, 2011
@scabug
Copy link
Author

scabug commented Jan 14, 2014

@paulp said:
Maybe you know this by now, but the transcript says "scala implicits.scala" which means you were compiling with fsc. The "one hour between subsequent runs of scalac" is the 30 minute inactivity timeout for the compile server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant