mirror of https://github.com/astral-sh/ruff
## 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> |
||
|---|---|---|
| .. | ||
| inline | ||
| invalid | ||
| valid | ||
| .editorconfig | ||