ruff/crates/ruff_python_parser/src
Andrew Gallant 6a1fa4778f
Reject more syntactically invalid Python programs (#8524)
## Summary

This commit adds some additional error checking to the parser such that
assignments that are invalid syntax are rejected. This covers the
obvious cases like `5 = 3` and some not so obvious cases like `x + y =
42`.

This does add an additional recursive call to the parser for the cases
handling assignments. I had initially been concerned about doing this,
but `set_context` is already doing recursion during assignments, so I
didn't feel as though this was changing any fundamental performance
characteristics of the parser. (Also, in practice, I would expect any
such recursion here to be quite shallow since the recursion is done on
the target of an assignment. Such things are rarely nested much in
practice.)

Fixes #6895

## Test Plan

I've added unit tests covering every case that is detected as invalid on
an `Expr`.
2023-11-07 07:16:06 -05:00
..
lexer perf(parser): use memchr for lexing comments (#8193) 2023-10-27 02:07:43 +01:00
snapshots Reject more syntactically invalid Python programs (#8524) 2023-11-07 07:16:06 -05:00
context.rs Remove Parse trait (#6235) 2023-08-01 18:35:03 +02:00
function.rs Move Ranged into ruff_text_size (#6919) 2023-08-27 14:12:51 -04:00
invalid.rs Reject more syntactically invalid Python programs (#8524) 2023-11-07 07:16:06 -05:00
lexer.rs Reject more syntactically invalid Python programs (#8524) 2023-11-07 07:16:06 -05:00
lib.rs Reject more syntactically invalid Python programs (#8524) 2023-11-07 07:16:06 -05:00
parser.rs Fix range of unparenthesized tuple subject in match statement (#8101) 2023-10-22 19:58:33 -04:00
python.lalrpop Reject more syntactically invalid Python programs (#8524) 2023-11-07 07:16:06 -05:00
python.rs Reject more syntactically invalid Python programs (#8524) 2023-11-07 07:16:06 -05:00
soft_keywords.rs Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
string.rs Fix panic with 8 in octal escape (#8356) 2023-10-30 14:42:15 +01:00
token.rs Add support for PEP 701 (#7376) 2023-09-29 02:55:39 +00:00
typing.rs Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00