Skip to content

Commit

Permalink
Update error messages and test snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
imaqtkatt committed Jul 25, 2024
1 parent 83a536e commit 360b044
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/imp/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ impl<'a> PyParser<'a> {
if nxt_indent != *indent {
return self
.expected_indent(*indent, nxt_indent)
.or(self.expected_spanned("else or elif", self.index..self.index + 1));
.or(self.expected_spanned("'else' or 'elif'", self.index..self.index + 1));
}
let mut elifs = Vec::new();
while self.try_parse_keyword("elif") {
Expand All @@ -592,7 +592,7 @@ impl<'a> PyParser<'a> {
if nxt_indent != *indent {
return self
.expected_indent(*indent, nxt_indent)
.or(self.expected_spanned("else or elif", self.index..self.index + 1));
.or(self.expected_spanned("'else' or 'elif'", self.index..self.index + 1));
}
elifs.push((cond, then));
}
Expand Down Expand Up @@ -634,7 +634,7 @@ impl<'a> PyParser<'a> {
self.consume_new_line()?;
indent.enter_level();

self.consume_indent_exactly(*indent).or(self.expected_spanned("case", self.index..self.index + 1))?;
self.consume_indent_exactly(*indent).or(self.expected_spanned("'case'", self.index..self.index + 1))?;
let (case, mut nxt_indent) = self.parse_match_case(indent)?;
let mut arms = vec![case];
while nxt_indent == *indent {
Expand Down Expand Up @@ -734,7 +734,7 @@ impl<'a> PyParser<'a> {
if nxt_indent != *indent {
return self
.expected_indent(*indent, nxt_indent)
.or(self.expected_spanned("case", self.index..self.index + 1));
.or(self.expected_spanned("'case'", self.index..self.index + 1));
}
let (case, stmt, nxt_indent_) = self.parse_switch_case(indent)?;
nxt_indent = nxt_indent_;
Expand Down Expand Up @@ -799,7 +799,7 @@ impl<'a> PyParser<'a> {
self.consume_new_line()?;
indent.enter_level();

self.consume_indent_exactly(*indent).or(self.expected_spanned("case", self.index..self.index + 1))?;
self.consume_indent_exactly(*indent).or(self.expected_spanned("'case'", self.index..self.index + 1))?;
let (case, mut nxt_indent) = self.parse_match_case(indent)?;
let mut arms = vec![case];
while nxt_indent == *indent {
Expand Down Expand Up @@ -830,7 +830,7 @@ impl<'a> PyParser<'a> {
self.consume_new_line()?;
indent.enter_level();

self.consume_indent_exactly(*indent).or(self.expected_spanned("when", self.index..self.index + 1))?;
self.consume_indent_exactly(*indent).or(self.expected_spanned("'when'", self.index..self.index + 1))?;
self.parse_keyword("when")?;
let cond = self.parse_expr(true, false)?;
self.skip_trivia_inline()?;
Expand All @@ -845,7 +845,7 @@ impl<'a> PyParser<'a> {
if nxt_indent != *indent {
return self
.expected_indent(*indent, nxt_indent)
.or(self.expected_spanned("else", self.index..self.index + 1));
.or(self.expected_spanned("'else'", self.index..self.index + 1));
}
self.parse_keyword("else")?;
self.skip_trivia_inline()?;
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/compile_file__elif_no_else.bend.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ input_file: tests/golden_tests/compile_file/elif_no_else.bend
---
Errors:
In tests/golden_tests/compile_file/elif_no_else.bend :
[1m- expected:[0m else or elif
[1m- expected:[0m 'else' or 'elif'
- detected: end of input
 6 |  
2 changes: 1 addition & 1 deletion tests/snapshots/parse_file__bend_missing_else.bend.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ input_file: tests/golden_tests/parse_file/bend_missing_else.bend
---
Errors:
In tests/golden_tests/parse_file/bend_missing_else.bend :
[1m- expected:[0m else
[1m- expected:[0m 'else'
- detected:
 14 | def main():
2 changes: 1 addition & 1 deletion tests/snapshots/parse_file__fold_missing_case.bend.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ input_file: tests/golden_tests/parse_file/fold_missing_case.bend
---
Errors:
In tests/golden_tests/parse_file/fold_missing_case.bend :
[1m- expected:[0m case
[1m- expected:[0m 'case'
- detected: end of input
 4 |  
2 changes: 1 addition & 1 deletion tests/snapshots/parse_file__if_missing_else.bend.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ input_file: tests/golden_tests/parse_file/if_missing_else.bend
---
Errors:
In tests/golden_tests/parse_file/if_missing_else.bend :
[1m- expected:[0m else or elif
[1m- expected:[0m 'else' or 'elif'
- detected: end of input
 5 |  
2 changes: 1 addition & 1 deletion tests/snapshots/parse_file__match_missing_case.bend.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ input_file: tests/golden_tests/parse_file/match_missing_case.bend
---
Errors:
In tests/golden_tests/parse_file/match_missing_case.bend :
[1m- expected:[0m case
[1m- expected:[0m 'case'
- detected: end of input
 4 |  

0 comments on commit 360b044

Please sign in to comment.