tail-recursive function is only a recursion so it does not resolve stackoverflow, but when you add tailrec into the declaration, compiler will translate it to a looping. So
- tail-recursive function = recursion -> stackoverflow
- tail-recursive function + tailrec -> no more stackoverflow