mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 04:05:31 +02:00
Fix parser recovery after error (#8798)
# Description This fixes the parser recovery after the first error (at least the main culprit), where `parse_value` was not able to properly parse `any` values after the first error. fixes #8796 # User-Facing Changes None # Tests + Formatting Don't forget to add tests that cover your changes. 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 - `cargo run -- crates/nu-utils/standard_library/tests.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` # 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:
@ -4423,6 +4423,8 @@ pub fn parse_value(
|
||||
span: Span,
|
||||
shape: &SyntaxShape,
|
||||
) -> Expression {
|
||||
trace!("parsing: value: {}", shape);
|
||||
|
||||
let bytes = working_set.get_span_contents(span);
|
||||
|
||||
if bytes.is_empty() {
|
||||
@ -4595,7 +4597,7 @@ pub fn parse_value(
|
||||
if starting_error_count == working_set.parse_errors.len() {
|
||||
return s;
|
||||
} else {
|
||||
match working_set.parse_errors.first() {
|
||||
match working_set.parse_errors.get(starting_error_count) {
|
||||
Some(ParseError::Expected(_, _)) => {
|
||||
working_set.parse_errors.truncate(starting_error_count);
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user