Gracefully handle deeply nested expressions, instead of blowing the stack #788
Labels
accepting contributions
Issues that are suitable to be worked on by anybody, not just maintainers
bug
Defects, unintended behaviour, etc
compiler
Changes related to the compiler
Please describe the bug
When parsing deeply nested expressions such as
{{{{ repeat a lot of times }}}}
, it's possible to consume all stack space and trigger a stack overflow. This is because our parser is implemented as a recursive descent parser, and specifically recurses to parse nested expressions.To prevent this from happening, we should enforce a maximum nesting depth for expressions. This limit should be 64 such that it's unlikely to ever be hit in real code, but still protects against accidents.
This issue was first reported in #782. A (better) proposal on how to resolve this is found in #782 (comment).
Operating system
Fedora
Inko version
main
The text was updated successfully, but these errors were encountered: