ruff/crates/ruff_python_parser/resources/inline/err
Dhruv Manilawala d3cd61f804
Use empty range when there's "gap" in token source (#11032)
## Summary

This fixes a bug where the parser would panic when there is a "gap" in
the token source.

What's a gap?

The reason it's `<=` instead of just `==` is because there could be
whitespaces between
the two tokens. For example:

```python
#     last token end
#     | current token (newline) start
#     v v
def foo \n
#      ^
#      assume there's trailing whitespace here
```

Or, there could tokens that are considered "trivia" and thus aren't
emitted by the token
source. These are comments and non-logical newlines. For example:

```python
#     last token end
#     v
def foo # comment\n
#                ^ current token (newline) start
```

In either of the above cases, there's a "gap" between the end of the
last token and start
of the current token.

## Test Plan

Add test cases and update the snapshots.
2024-04-19 11:36:26 +00:00
..
ann_assign_stmt_invalid_annotation.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
ann_assign_stmt_invalid_target.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
ann_assign_stmt_invalid_value.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
ann_assign_stmt_missing_rhs.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
ann_assign_stmt_type_alias_annotation.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
assert_empty_msg.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
assert_empty_test.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
assert_invalid_msg_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
assert_invalid_test_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
assign_stmt_invalid_target.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
assign_stmt_invalid_value_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
assign_stmt_keyword_target.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
assign_stmt_missing_rhs.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
async_unexpected_token.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
aug_assign_stmt_invalid_target.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
aug_assign_stmt_invalid_value.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
aug_assign_stmt_missing_rhs.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
case_expect_indented_block.py Expect indented case block instead of match stmt (#11033) 2024-04-19 16:46:15 +05:30
class_def_empty_body.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
class_def_missing_name.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
class_def_unclosed_type_param_list.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
clause_expect_indented_block.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
clause_expect_single_statement.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
comprehension_missing_for_after_async.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
decorator_invalid_expression.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
decorator_missing_expression.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
decorator_missing_newline.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
decorator_unexpected_token.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
del_incomplete_target.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
del_stmt_empty.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
dotted_name_multiple_dots.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
except_stmt_invalid_expression.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
except_stmt_missing_as_name.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
except_stmt_missing_exception.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
except_stmt_missing_exception_and_as_name.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
except_stmt_unparenthesized_tuple.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
f_string_empty_expression.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
f_string_invalid_conversion_flag_name_tok.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
f_string_invalid_conversion_flag_other_tok.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
f_string_invalid_starred_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
f_string_lambda_without_parentheses.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
f_string_unclosed_lbrace.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
f_string_unclosed_lbrace_in_format_spec.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
for_in_target_postfix_expr.py Reset FOR_TARGET context for all kinds of parentheses (#11009) 2024-04-18 19:37:50 +05:30
for_stmt_invalid_iter_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
for_stmt_invalid_target.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
for_stmt_missing_in_keyword.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
for_stmt_missing_iter.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
for_stmt_missing_target.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
from_import_dotted_names.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
from_import_empty_names.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
from_import_missing_module.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
from_import_missing_rpar.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
from_import_star_with_other_names.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
from_import_unparenthesized_trailing_comma.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
function_def_empty_body.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
function_def_invalid_return_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
function_def_missing_identifier.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
function_def_missing_return_type.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
function_def_unclosed_parameter_list.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
function_def_unclosed_type_param_list.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
function_def_unparenthesized_return_types.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
global_stmt_empty.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
global_stmt_expression.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
global_stmt_trailing_comma.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
if_stmt_elif_missing_colon.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
if_stmt_empty_body.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
if_stmt_invalid_elif_test_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
if_stmt_invalid_test_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
if_stmt_missing_colon.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
if_stmt_missing_test.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
if_stmt_misspelled_elif.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
implicitly_concatenated_unterminated_string.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
implicitly_concatenated_unterminated_string_multiline.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
import_alias_missing_asname.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
import_stmt_empty.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
import_stmt_parenthesized_names.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
import_stmt_star_import.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
import_stmt_trailing_comma.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
invalid_byte_literal.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
invalid_del_target.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
invalid_fstring_literal_element.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
invalid_string_literal.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
lambda_body_with_starred_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
lambda_body_with_yield_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
match_stmt_expect_indented_block.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
match_stmt_expected_case_block.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
match_stmt_invalid_guard_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
match_stmt_invalid_subject_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
match_stmt_missing_guard_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
match_stmt_missing_pattern.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
match_stmt_no_newline_before_case.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
match_stmt_single_starred_subject.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
mixed_bytes_and_non_bytes_literals.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
multiple_clauses_on_same_line.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
node_range_with_gaps.py Use empty range when there's "gap" in token source (#11032) 2024-04-19 11:36:26 +00:00
nonlocal_stmt_empty.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
nonlocal_stmt_expression.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
nonlocal_stmt_trailing_comma.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
param_missing_annotation.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
param_missing_default.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
param_with_invalid_annotation.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
param_with_invalid_default.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
param_with_invalid_star_annotation.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_duplicate_names.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_expected_after_star_separator.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_kwarg_after_star_separator.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_multiple_kwargs.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_multiple_slash_separator.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_multiple_star_separator.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_multiple_varargs.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_no_arg_before_slash.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_non_default_after_default.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_star_after_slash.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_star_separator_after_star_param.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_var_keyword_with_default.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
params_var_positional_with_default.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
parenthesized_compare_expr_in_for.py Reset FOR_TARGET context for all kinds of parentheses (#11009) 2024-04-18 19:37:50 +05:30
raise_stmt_invalid_cause.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
raise_stmt_invalid_exc.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
raise_stmt_unparenthesized_tuple_cause.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
raise_stmt_unparenthesized_tuple_exc.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
return_stmt_invalid_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
simple_and_compound_stmt_on_same_line.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
simple_and_compound_stmt_on_same_line_in_block.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
simple_stmts_on_same_line.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
simple_stmts_on_same_line_in_block.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
try_stmt_invalid_order.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
try_stmt_missing_except_finally.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
try_stmt_misspelled_except.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
type_alias_incomplete_stmt.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
type_alias_invalid_value_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
type_param_invalid_bound_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
type_param_missing_bound.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
type_param_param_spec_bound.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
type_param_type_var_tuple_bound.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
unterminated_fstring_newline_recovery.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
while_stmt_invalid_test_expr.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
while_stmt_missing_colon.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
while_stmt_missing_test.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
with_items_parenthesized_missing_comma.py Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30