rcl/golden/error/recursion_stack_overflow_operator.test
Ruud van Asseldonk 240bb04bf1 Guard against stack overflow in more places
This is still not exhaustive, but it at least guards against some cases
discovered by the fuzzer.

Tail calls would likely solve this, though maybe even that is not
enough, you _could_ overflow the native stack with a very deeply nested
expression. The eventual solution might be to have a bytecode
interpreter with jumps, but for now, let's patch it ad-hoc ...
2023-12-29 17:31:53 +01:00

44 lines
1 KiB
Text

// Even with a limit on the depth of function calls, if every call causes a very
// deep stack frame, for example due to naively evaluating unary operators, we
// can still overflow the native stack.
let f = f => ------------f(f);
f(f)
# output:
stdin:4:19
4 │ let f = f => ------------f(f);
╵ ^
Error: Evaluation budget exceeded. This expression exceeds the maximum evaluation depth of 150.
stdin:4:27
4 │ let f = f => ------------f(f);
╵ ^
In call to function.
stdin:4:27
4 │ let f = f => ------------f(f);
╵ ^
In call to function.
stdin:4:27
4 │ let f = f => ------------f(f);
╵ ^
In call to function.
stdin:4:27
4 │ let f = f => ------------f(f);
╵ ^
In call to function.
stdin:4:27
4 │ let f = f => ------------f(f);
╵ ^
In call to function.
Note: The call stack is too deep to display in full. Only the innermost calls are shown above.