ensure that when nu evaluates files, it allows early returns (#7415)

# Description

Fixes #7301.

# User-Facing Changes

`return` can now be used in scripts without explicit `def main`.

# Tests + Formatting

Don't forget to add tests that cover your changes. (I'm not sure how to
test this.)

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
This commit is contained in:
pwygab
2023-02-02 07:02:27 +08:00
committed by GitHub
parent c130ca1bc6
commit 24d7227e27
10 changed files with 56 additions and 8 deletions

View File

@ -131,6 +131,7 @@ pub(crate) fn read_default_env_file(engine_state: &mut EngineState, stack: &mut
config_file.as_bytes(),
"default_env.nu",
PipelineData::empty(),
false,
);
info!("read_config_file {}:{}:{}", file!(), line!(), column!());
@ -167,6 +168,7 @@ fn eval_default_config(
"default_config.nu"
},
PipelineData::empty(),
false,
);
// Merge the environment in case env vars changed in the config