ruff/crates/ruff_python_parser/resources
Dan Parizher 474b00568a
[`parser`] Fix panic when parsing IPython escape command expressions (#21480)
## Summary

Fixes a panic when parsing IPython escape commands with `Help` kind
(`?`) in expression contexts. The parser now reports an error instead of
panicking.

Fixes #21465.

## Problem

The parser panicked with `unreachable!()` in
`parse_ipython_escape_command_expression` when encountering escape
commands with `Help` kind (`?`) in expression contexts, where only
`Magic` (`%`) and `Shell` (`!`) are allowed.

## Approach

Replaced the `unreachable!()` panic with error handling that adds a
`ParseErrorType::OtherError` and continues parsing, returning a valid
AST node with the error attached.

## Test Plan

Added `test_ipython_escape_command_in_with_statement` and
`test_ipython_help_escape_command_as_expression` to verify the fix.

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2025-11-24 05:40:27 +00:00
..
inline [`parser`] Fix panic when parsing IPython escape command expressions (#21480) 2025-11-24 05:40:27 +00:00
invalid Fix typos (#17988) 2025-05-09 14:57:14 -04:00
valid Disallow implicit concatenation of t-strings and other string types (#19485) 2025-07-27 12:41:03 +00:00
.editorconfig Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30