astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
33.38k stars 1.11k forks source link

Red Knot panics when analyzing black #13478

Closed MichaReiser closed 3 weeks ago

MichaReiser commented 2 months ago
sharkdp commented 1 month ago

With #14091 merged (which fixed the issue in src/blib2to3/pgen2/driver.py), we can now run a release version of red-knot on the full black codebase. (The other two issues likely have been fixed in the meantime?)

However, the debug version still fails due to some new debug assertions:

thread '<unnamed>' panicked at crates/red_knot_python_semantic/src/types/infer.rs:3752:17:
assertion `left == right` failed
  left: Invalid
 right: Load
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at crates/red_knot_python_semantic/src/types/infer.rs:3752:17:
assertion `left == right` failed
  left: Invalid
 right: Load

https://github.com/astral-sh/ruff/blob/a7a78f939c2c393aa846b97fdbd32c1c3bfc7b34/crates/red_knot_python_semantic/src/types/infer.rs#L3751-L3760

dhruvmanila commented 3 weeks ago

For context, the ExprContext::Invalid is used where the expressions are invalid i.e., these files contains syntax errors (#13778).

sharkdp commented 3 weeks ago

The two remaining panics from the original description and the assertions mentioned in my previous comment are now resolved.

But there is a new panic, which I have opened a separate ticket for (#14307) and added to the list above.

sharkdp commented 3 weeks ago

Red knot can now run on the full black repository without any panics, allowing us to use it as a benchmark.

Currently it takes 120 ms for a cold run (40 ms for the src/ folder).