mirror of
https://github.com/ruuda/rcl.git
synced 2025-12-23 04:47:19 +00:00
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 ...
44 lines
1 KiB
Text
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.
|