parse_execution: Use an exhaustive match instead of an assert

This could also be "cancel", which we didn't check and instead
asserted out.
This commit is contained in:
Fabian Boehm 2024-04-27 08:13:41 +02:00
parent fb99edae92
commit 1503be4287

View file

@ -538,14 +538,16 @@ impl<'a> ParseExecutionContext {
Some(&mut errors),
false,
);
if expand_err == ExpandResultCode::error {
match expand_err.result {
ExpandResultCode::error => {
// Issue #5812 - the expansions were done on the command token,
// excluding prefixes such as " " or "if ".
// This means that the error positions are relative to the beginning
// of the token; we need to make them relative to the original source.
parse_error_offset_source_start(&mut errors, pos_of_command_token);
return self.report_errors(ctx, STATUS_ILLEGAL_CMD.unwrap(), &errors);
} else if expand_err == ExpandResultCode::wildcard_no_match {
}
ExpandResultCode::wildcard_no_match => {
return report_error!(
self,
ctx,
@ -555,7 +557,11 @@ impl<'a> ParseExecutionContext {
&self.node_source(statement)
);
}
assert!(expand_err == ExpandResultCode::ok);
ExpandResultCode::cancel => {
return EndExecutionReason::cancelled;
}
ExpandResultCode::ok => {}
}
// Complain if the resulting expansion was empty, or expanded to an empty string.
// For no-exec it's okay, as we can't really perform the expansion.