sam701 / syconf

A simple configuration language that keeps your config files lean
Apache License 2.0
3 stars 1 forks source link

Stack overflow by recursive call #16

Closed sam701 closed 3 years ago

sam701 commented 3 years ago

This code leads to stack overflow

let ff = (x, acc, f) =>
    if x == 0 then acc else f(x-1, acc+1, f)

in

ff(2, 0, ff)

Error:

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
sam701 commented 3 years ago

The reason is that both if-branches are evaluated first.