nushell/src
TrMen 4b91ed57dd
Enforce call stack depth limit for all calls (#11729)
# Description
Previously, only direcly-recursive calls were checked for recursion
depth. But most recursive calls in nushell are mutually recursive since
expressions like `for`, `where`, `try` and `do` all execute a separte
block.

```nushell
def f [] {
    do { f }
}
```
Calling `f` would crash nushell with a stack overflow.

I think the only general way to prevent such a stack overflow is to
enforce a maximum call stack depth instead of only disallowing directly
recursive calls.

This commit also moves that logic into `eval_call()` instead of
`eval_block()` because the recursion limit is tracked in the `Stack`,
but not all blocks are evaluated in a new stack. Incrementing the
recursion depth of the caller's stack would permanently increment that
for all future calls.

Fixes #11667

# User-Facing Changes
Any function call can now fail with `recursion_limit_reached` instead of
just directly recursive calls. Mutually-recursive calls no longer crash
nushell.

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2024-02-08 06:42:24 +08:00
..
tests Enforce call stack depth limit for all calls (#11729) 2024-02-08 06:42:24 +08:00
command.rs Add CLI flag to disable history (#11550) 2024-01-17 09:40:59 -06:00
config_files.rs Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
ide.rs Make only_buffer_difference: true work (#11488) 2024-01-11 11:58:14 -06:00
logger.rs Use variable names directly in the format strings (#7906) 2023-01-29 19:37:54 -06:00
main.rs Add CLI flag to disable history (#11550) 2024-01-17 09:40:59 -06:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
run.rs allow --login to be used with nu's --commands parameter (#10253) 2023-09-06 13:27:16 -05:00
signals.rs Simplify SIGQUIT handling (#11381) 2023-12-21 17:00:38 +01:00
terminal.rs Do not block signals for child processes (#11402) 2024-01-15 16:08:21 -06:00
test_bins.rs Apply nightly clippy fixes (#11508) 2024-01-15 10:52:16 +08:00
tests.rs Spread operator for list literals (#11006) 2023-11-22 23:10:08 +02:00

Nushell REPL

This directory contains the main Nushell REPL (read eval print loop) as part of the CLI portion of Nushell, which creates the nu binary itself.

Current versions of the nu binary will use the Nu argument parsing logic to parse the commandline arguments passed to nu, leaving the logic here to be a thin layer around what the core libraries.