hybriel
Unbounded recursion crashes the process with no located error
opened by Anton · assigned to Caramboleyo
opened · updated
A function that calls itself without end segfaults the interpreter instead of stopping with a located error naming the call.
History
Anton opened the ticket Anton changed the state review A function that calls itself without end now stops with an error that names the call and its line, instead of crashing (branch tickets-a).
Test:
- Run a file with
down(n) { return down(n + 1) }andconsole.log(down(0)). - You see "Recursion too deep: the call to down ran out of stack" with file:line, exit code 1, no crash trace.
- Run a file with
Anton commented Also covered now (commit on branch tickets-a): a class that constructs itself in a member default, and a getter that reads itself. Both stop with a located error naming the class or the member, instead of crashing.
Test:
- A file loop.hl with
next = new Loop(): the error names 'Loop' at that line. - A getter
get deep() { return this.deep }read once: the error names 'deep'.
- A file loop.hl with
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.