mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 22:21:15 -03:00
Refine errors on "begin; case"
This will also give better errors for unbalanced braces (which are sigils for begin/end), see a following commit.
This commit is contained in:
@@ -2970,6 +2970,15 @@ fn did_visit_fields_of<'a>(&'a mut self, node: &'a dyn NodeMut, flow: VisitResul
|
||||
};
|
||||
|
||||
if let Some((header_kw_range, enclosing_stmt)) = header {
|
||||
let next_token = self.peek_token(0);
|
||||
if next_token.typ == ParseTokenType::string
|
||||
&& matches!(
|
||||
next_token.keyword,
|
||||
ParseKeyword::kw_case | ParseKeyword::kw_else | ParseKeyword::kw_end
|
||||
)
|
||||
{
|
||||
self.consume_excess_token_generating_error();
|
||||
}
|
||||
parse_error_range!(
|
||||
self,
|
||||
header_kw_range,
|
||||
|
||||
@@ -602,7 +602,7 @@ macro_rules! validate {
|
||||
validate!("if true ; end ; else", ParseErrorCode::unbalancing_else);
|
||||
|
||||
validate!("case", ParseErrorCode::unbalancing_case);
|
||||
validate!("if true ; case ; end", ParseErrorCode::generic);
|
||||
validate!("if true ; case ; end", ParseErrorCode::unbalancing_case);
|
||||
|
||||
validate!("true | and", ParseErrorCode::andor_in_pipeline);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user