mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-29 13:23:53 +08:00
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:
parent
fb99edae92
commit
1503be4287
|
@ -538,24 +538,30 @@ impl<'a> ParseExecutionContext {
|
||||||
Some(&mut errors),
|
Some(&mut errors),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
if expand_err == ExpandResultCode::error {
|
match expand_err.result {
|
||||||
// Issue #5812 - the expansions were done on the command token,
|
ExpandResultCode::error => {
|
||||||
// excluding prefixes such as " " or "if ".
|
// Issue #5812 - the expansions were done on the command token,
|
||||||
// This means that the error positions are relative to the beginning
|
// excluding prefixes such as " " or "if ".
|
||||||
// of the token; we need to make them relative to the original source.
|
// This means that the error positions are relative to the beginning
|
||||||
parse_error_offset_source_start(&mut errors, pos_of_command_token);
|
// of the token; we need to make them relative to the original source.
|
||||||
return self.report_errors(ctx, STATUS_ILLEGAL_CMD.unwrap(), &errors);
|
parse_error_offset_source_start(&mut errors, pos_of_command_token);
|
||||||
} else if expand_err == ExpandResultCode::wildcard_no_match {
|
return self.report_errors(ctx, STATUS_ILLEGAL_CMD.unwrap(), &errors);
|
||||||
return report_error!(
|
}
|
||||||
self,
|
ExpandResultCode::wildcard_no_match => {
|
||||||
ctx,
|
return report_error!(
|
||||||
STATUS_UNMATCHED_WILDCARD.unwrap(),
|
self,
|
||||||
statement,
|
ctx,
|
||||||
WILDCARD_ERR_MSG,
|
STATUS_UNMATCHED_WILDCARD.unwrap(),
|
||||||
&self.node_source(statement)
|
statement,
|
||||||
);
|
WILDCARD_ERR_MSG,
|
||||||
|
&self.node_source(statement)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
ExpandResultCode::cancel => {
|
||||||
|
return EndExecutionReason::cancelled;
|
||||||
|
}
|
||||||
|
ExpandResultCode::ok => {}
|
||||||
}
|
}
|
||||||
assert!(expand_err == ExpandResultCode::ok);
|
|
||||||
|
|
||||||
// Complain if the resulting expansion was empty, or expanded to an empty string.
|
// 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.
|
// For no-exec it's okay, as we can't really perform the expansion.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user