Scala Programming Language
  1. Scala Programming Language
  2. SI-8146

Non-deterministic type errors and non-termination of scalac

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.3, Scala 2.11.0-M7
    • Component/s: Type Checker
    • Labels:
      None
    • Environment:

      Scala 2.11.0-M7

      Description

      The attached source code triggers non-deterministic behavior in the compiler. Trying to compile it has three possible results (not equally likely but all easily reproducible with a few dozen runs at most):

      1. The code compiles as excepted (~80% of the time):

      $ rm *.class 2>/dev/null; time ~/scala/scala-2.11.0-M7/bin/scalac HListBench.scala
      
      real	0m4.678s
      user	0m8.699s
      sys	0m0.205s
      

      2. The compiler does not terminate (in ~10% of the runs):

      $ rm *.class 2>/dev/null; time ~/scala/scala-2.11.0-M7/bin/scalac HListBench.scala
      ^C
      real	0m22.536s
      user	0m25.562s
      sys	0m0.214s
      

      -Ystatistics confirms that it's stuck in the typer (the last output is the summary for phase parser).

      3. The compiler aborts with a spurious type error (apparently a failure to find the required implicit conversion) (~10% of cases):

      $ rm *.class 2>/dev/null; time ~/scala/scala-2.11.0-M7/bin/scalac HListBench.scala
      HListBench.scala:65: error: type mismatch;
       found   : HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HCons[Column[Int],HNil.type]]]]]]]]]]]]]]]]]]]]]]]]]]]
       required: ProvenShape[syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.::[Int,syntax.HNil]]]]]]]]]]]]]]]]]]]]]]]]]]]]
          (which expands to)  ProvenShape[HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HCons[Int,HNil.type]]]]]]]]]]]]]]]]]]]]]]]]]]]]
          def * = c :: c :: c :: c :: c ::
                    ^
      one error found
      
      real	0m4.406s
      user	0m7.618s
      sys	0m0.172s
      

      This is possibly related to SI-4539. I tried to minimize the test case further but any attempt tipped the scales in one direction or the other, making it harder to reproduce all three cases reliably.

      (@moors, this is the issue I told you about last week)

        Issue Links

          Activity

          Hide
          Jason Zaugg added a comment - - edited

          I can reproduce. You had me worrying with your "at most about 20th", but the suspense was worth it:

          -----------------------
          Build number: 19
          -----------------------
          [info] Loading global plugins from /Users/jason/.sbt/0.13/plugins
          [info] Loading project definition from /Users/jason/code/slick-examples-ttyusupov/project
          [info] Set current project to slick-examples (in build file:/Users/jason/code/slick-examples-ttyusupov/)
          [success] Total time: 0 s, completed Feb 5, 2014 9:43:38 PM
          [info] Updating {file:/Users/jason/code/slick-examples-ttyusupov/}slick-examples-ttyusupov...
          [info] Resolving org.fusesource.jansi#jansi;1.4 ...
          [info] Done updating.
          [info] Compiling 1 Scala source to /Users/jason/code/slick-examples-ttyusupov/target/scala-2.10/classes...
          [error] /Users/jason/code/slick-examples-ttyusupov/src/main/scala/org/ty/Tables.scala:23: type mismatch;
          [error]  found   : scala.slick.collection.heterogenous.HCons[Long,scala.slick.collection.heterogenous.HCons[Long,scala.slick.collection.heterogenous.HCons[Option[String],scala.slick.collection.heterogenous.HCons[Option[String],scala.slick.collection.heterogenous.HCons[Option[String],scala.slick.collection.heterogenous.HCons[Option[String],scala.slick.collection.heterogenous.HCons[Option[St
          

          Thanks you so much for making it so easy to reproduce the failure! I'll take a deeper look tomorrow.

          Show
          Jason Zaugg added a comment - - edited I can reproduce. You had me worrying with your "at most about 20th", but the suspense was worth it: ----------------------- Build number: 19 ----------------------- [info] Loading global plugins from /Users/jason/.sbt/0.13/plugins [info] Loading project definition from /Users/jason/code/slick-examples-ttyusupov/project [info] Set current project to slick-examples (in build file:/Users/jason/code/slick-examples-ttyusupov/) [success] Total time: 0 s, completed Feb 5, 2014 9:43:38 PM [info] Updating {file:/Users/jason/code/slick-examples-ttyusupov/}slick-examples-ttyusupov... [info] Resolving org.fusesource.jansi#jansi;1.4 ... [info] Done updating. [info] Compiling 1 Scala source to /Users/jason/code/slick-examples-ttyusupov/target/scala-2.10/classes... [error] /Users/jason/code/slick-examples-ttyusupov/src/main/scala/org/ty/Tables.scala:23: type mismatch; [error] found : scala.slick.collection.heterogenous.HCons[Long,scala.slick.collection.heterogenous.HCons[Long,scala.slick.collection.heterogenous.HCons[Option[String],scala.slick.collection.heterogenous.HCons[Option[String],scala.slick.collection.heterogenous.HCons[Option[String],scala.slick.collection.heterogenous.HCons[Option[String],scala.slick.collection.heterogenous.HCons[Option[St Thanks you so much for making it so easy to reproduce the failure! I'll take a deeper look tomorrow.
          Hide
          Jason Zaugg added a comment -

          Darn. Just realised that the tag from which I build 2.10.4-RC2 didn't contain this fix. I'll need to cut another RC.

          Show
          Jason Zaugg added a comment - Darn. Just realised that the tag from which I build 2.10.4-RC2 didn't contain this fix. I'll need to cut another RC.
          Hide
          Adriaan Moors added a comment -

          Drad. Let's have a 1-week cycle for this RC. In general, I think RC1 (2 weeks) RC2 (1 week) RCn (1 week) final is a good rhythm.

          Show
          Adriaan Moors added a comment - Drad. Let's have a 1-week cycle for this RC. In general, I think RC1 (2 weeks) RC2 (1 week) RCn (1 week) final is a good rhythm.
          Hide
          Jason Zaugg added a comment - - edited

          I just confirmed that the test case builds every* time (*where N=30) with 2.10.4-SNAPSHOT. We'll cut RC3 from that. I'll wear the dunce hat for the day as penance for my mistagging...

          Show
          Jason Zaugg added a comment - - edited I just confirmed that the test case builds every* time (*where N=30) with 2.10.4-SNAPSHOT. We'll cut RC3 from that. I'll wear the dunce hat for the day as penance for my mistagging...
          Hide
          Adriaan Moors added a comment -

          Now you're donning your scalac bug wizard cap again: can this be closed (as fixed for 2.10.4-RC3 and 2.11.0-RC1)? It looks like the only commits not merged into master from 2.10.x are marked [nomaster] or [backport].

          Show
          Adriaan Moors added a comment - Now you're donning your scalac bug wizard cap again: can this be closed (as fixed for 2.10.4-RC3 and 2.11.0-RC1)? It looks like the only commits not merged into master from 2.10.x are marked [nomaster] or [backport] .

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Stefan Zeiger
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development