aboutsummaryrefslogtreecommitdiff
path: root/tests/debug/tailrec.scala
blob: f79514fa3a994608c50502b4ff40322191d0574e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
object Test {
  def fact(x: Int): Int = {
    if (x == 0)
      1
    else
      x * fact(x - 1) // TODO: incorrect this line when x = 0
  }


   def main(args: Array[String]): Unit = {
     val a = 1 + 2
     val b = a * 9     // [break] [step: fact]
     val c = fact(a)   // [step: x == 0] [step: fact(x - 1)] [step: x == 0] [cont]
     fact(0)           // [break] [step: x == 0] [step: 1] [step: fact(x - 1)] [step: print]
     print(c)          // [cont]
  }
}