Aladdin - Scala Bugtracking
[#1205] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Iulian fixed 2007-07-12 11:50:47.0
subject [contrib #678] tail recursion with finally
code
Using a script, with Scala 2.5.1-final


#! scala -savecompiled
!#

try
{
    def f(n: Int): Int =
    {
        if (0 < n)
            f(n - 1)
        else
            0
    }

    f(100000)
}
finally
{
}

or not using a script

object Test
{
    def main(args: Array[String]): Unit =
    {
        try
        {
            def f(n: Int): Int =
            {
                if (0 < n)
                    f(n - 1)
                else
                    0
            }

            f(100000)
        }
        finally
        {
        }
    }
}


Moving def f out of the try avoids the problem.

what happened
java.lang.StackOverflowError
what expected No output
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-07-12 12:05:21.0
Iulian  edited on  2007-07-12 17:01:49.0