Skip to content

[Panic] --preview --select ANN,PLR1712 crashes Ruff 0.15.3 #23587

Description

@dscorbett

Summary

$ echo 'x = id' | RUST_BACKTRACE=full ruff --isolated check - --preview --select ANN,PLR1712

error: Ruff crashed. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BPanic%5D

...quoting the executed command, along with the relevant file contents and `pyproject.toml` settings, we'd be very appreciative!


thread 'main' (6913397) panicked at crates/ruff_python_semantic/src/definition.rs:285:26:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:        0x100f33c58 - __mh_execute_header
   1:        0x100201c0c - __mh_execute_header
   2:        0x100f31fc4 - __mh_execute_header
   3:        0x100f32200 - __mh_execute_header
   4:        0x1005c335c - __mh_execute_header
   5:        0x100f31be8 - __mh_execute_header
   6:        0x100f51de8 - __mh_execute_header
   7:        0x100f51da4 - __mh_execute_header
   8:        0x100f51d98 - __mh_execute_header
   9:        0x1010261d8 - __mh_execute_header
  10:        0x10102620c - __mh_execute_header
  11:        0x100a2c5b0 - __mh_execute_header
  12:        0x100879ce4 - __mh_execute_header
  13:        0x1009d71a4 - __mh_execute_header
  14:        0x1009e19b0 - __mh_execute_header
  15:        0x1005ce524 - __mh_execute_header
  16:        0x1005ba654 - __mh_execute_header
  17:        0x1005b68e8 - __mh_execute_header
  18:        0x1006034f8 - __mh_execute_header
  19:        0x100609f18 - __mh_execute_header
  20:        0x100603ffc - __mh_execute_header

Version

ruff 0.15.3 (e5f2f36 2026-02-26)

Activity

  1. added
    bugAn issue describing something that isn't working, or a PR that fixes a bug
    on Feb 26, 2026
  2. self-assigned this
    on Feb 26, 2026
  3. ntBre commented on Feb 26, 2026

    @ntBre
    Contributor

    Wow, thank you! It turns out that any rule that analyzes definitions will work because that causes the Definitions to be taken out of the semantic model:

    let definitions = std::mem::take(&mut checker.semantic.definitions);

    and then causes this indexing operation to panic:

    let module = self[DefinitionId::module()].as_module()?;

  4. added a commit that references this issue on Feb 26, 2026
    26cfcbf
  5. added a commit that references this issue on Feb 26, 2026
    fd09d37
  6. added a commit that references this issue on Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugAn issue describing something that isn't working, or a PR that fixes a bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions