Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.0-M3, Scala 2.10.0
    • Component/s: Pattern Matcher
    • Labels:
      None
    • Environment:

      Scala version 2.10.0-M1 (Java HotSpot(TM) Client VM, Java 1.6.0_25). Win32. 32 bit JDK.

      Description

      The following tail recursive function is not optimized when using -Yvirtpatmat

      def f[T](l: List[T]): Int = l match { case x :: xs => f(xs) case Nil => 0 }
      f(List.fill(10000)(0))
      

      will cause a stack overflow.

      Also when using @annotation.tailrec the compiler will report that f contains a call not in tail position.

        Activity

        Hide
        Jason Zaugg added a comment -

        Fixed in https://github.com/scala/scala/commit/cd3d342. I'm not sure if there is a test case.

        Show
        Jason Zaugg added a comment - Fixed in https://github.com/scala/scala/commit/cd3d342 . I'm not sure if there is a test case.
        Hide
        Simon Ochsenreither added a comment -
        Show
        Simon Ochsenreither added a comment - Now there is: https://github.com/scala/scala/pull/543 Thanks!
        Show
        Simon Ochsenreither added a comment - Closing after test is merged in https://github.com/scala/scala/commit/5797aab80e960e41301006242ca30979ee39741b .

          People

          • Assignee:
            Adriaan Moors
            Reporter:
            huynhjl
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development