mirror of
https://github.com/nushell/nushell.git
synced 2025-08-11 08:15:08 +02:00
fix(parser): skip eval_const if parsing errors detected to avoid panic (#15364)
Fixes #14972 #15321 #14706 # Description Early returns `NotAConstant` if parsing errors exist in the subexpression. I'm not sure when the span of a block will be None, and whether there're better ways to handle none block spans, like a more suitable ShellError type. # User-Facing Changes # Tests + Formatting +1, but possibly not the easiest way to do it. # After Submitting
This commit is contained in:
@ -1140,6 +1140,25 @@ This is an internal Nushell error, please file an issue https://github.com/nushe
|
||||
span: Span,
|
||||
},
|
||||
|
||||
/// TODO: Get rid of this error by moving the check before evaluation
|
||||
///
|
||||
/// Tried evaluating of a subexpression with parsing error
|
||||
///
|
||||
/// ## Resolution
|
||||
///
|
||||
/// Fix the parsing error first.
|
||||
#[error("Found parsing error in expression.")]
|
||||
#[diagnostic(
|
||||
code(nu::shell::parse_error_in_constant),
|
||||
help(
|
||||
"This expression is supposed to be evaluated into a constant, which means error-free."
|
||||
)
|
||||
)]
|
||||
ParseErrorInConstant {
|
||||
#[label("Parsing error detected in expression")]
|
||||
span: Span,
|
||||
},
|
||||
|
||||
/// Tried assigning non-constant value to a constant
|
||||
///
|
||||
/// ## Resolution
|
||||
|
Reference in New Issue
Block a user