mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:55:40 +02:00
Fix panic when redirecting nothing (#12970)
# Description Fixes #12969 where the parser can panic if a redirection is applied to nothing / an empty command. # Tests + Formatting Added a test.
This commit is contained in:
@ -93,6 +93,13 @@ pub enum ParseError {
|
||||
#[label = "second redirection"] Span,
|
||||
),
|
||||
|
||||
#[error("Unexpected redirection.")]
|
||||
#[diagnostic(code(nu::parser::unexpected_redirection))]
|
||||
UnexpectedRedirection {
|
||||
#[label = "redirecting nothing"]
|
||||
span: Span,
|
||||
},
|
||||
|
||||
#[error("{0} is not supported on values of type {3}")]
|
||||
#[diagnostic(code(nu::parser::unsupported_operation))]
|
||||
UnsupportedOperationLHS(
|
||||
@ -564,6 +571,7 @@ impl ParseError {
|
||||
ParseError::ShellErrRedirect(s) => *s,
|
||||
ParseError::ShellOutErrRedirect(s) => *s,
|
||||
ParseError::MultipleRedirections(_, _, s) => *s,
|
||||
ParseError::UnexpectedRedirection { span } => *span,
|
||||
ParseError::UnknownOperator(_, _, s) => *s,
|
||||
ParseError::InvalidLiteral(_, _, s) => *s,
|
||||
ParseError::LabeledErrorWithHelp { span: s, .. } => *s,
|
||||
|
Reference in New Issue
Block a user