Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[red-knot] Ensure differently ordered unions are considered equivalent when they appear inside tuples inside top-level intersections #15743

Merged
merged 1 commit into from
Jan 25, 2025

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Jan 25, 2025

Summary

Another oversight in type equivalence, that I spotted by re-reading some of the code in types.rs. In this round of type-equivalence whackamole, we were not considering tuple[P | Q] & R to be equivalent to tuple[Q | P] & R. This bug only manifested if a union was nested directly inside a tuple nested directly inside a top-level intersection.

It sure would be easier to ensure we got all these cases right if unions only ever appeared in a canonical order 😉 I'm not yet pushing for us to reconsider the direction we went in #15516, but there is definitely a maintenance burden here.

Test Plan

  • New mdtest added that fails on main
  • Checked that all stable property tests continue to pass

…t when they appear inside tuples inside top-level intersections
@AlexWaygood AlexWaygood added the red-knot Multi-file analysis & type inference label Jan 25, 2025
@AlexWaygood
Copy link
Member Author

Neutral on codspeed

@AlexWaygood AlexWaygood merged commit c824140 into main Jan 25, 2025
21 checks passed
@AlexWaygood AlexWaygood deleted the alex/tuples-in-intersections branch January 25, 2025 18:19
dcreager added a commit that referenced this pull request Jan 27, 2025
* main:
  Run `cargo update` (#15769)
  [red-knot] Document public symbol type inferece (#15766)
  Update dawidd6/action-download-artifact action to v8 (#15760)
  Update NPM Development dependencies (#15758)
  Update pre-commit dependencies (#15756)
  Update dependency ruff to v0.9.3 (#15755)
  Update dependency mdformat-mkdocs to v4.1.2 (#15754)
  Update Rust crate uuid to v1.12.1 (#15753)
  Update Rust crate unicode-ident to v1.0.15 (#15752)
  Fix docstring in ruff_annotate_snippets (#15748)
  Update Rust crate insta to v1.42.1 (#15751)
  Update Rust crate clap to v4.5.27 (#15750)
  Add references to `trio.run_process` and `anyio.run_process` (#15761)
  [`ruff`] Do not emit diagnostic when all arguments to `zip()` are variadic (`RUF058`) (#15744)
  [red-knot] Ensure differently ordered unions are considered equivalent when they appear inside tuples inside top-level intersections (#15743)
  [red-knot] Ensure differently ordered unions and intersections are understood as equivalent even inside arbitrarily nested tuples (#15740)
  [red-knot] Promote the `all_type_pairs_are_assignable_to_their_union` property test to stable (#15739)
  [`pylint`] Do not trigger `PLR6201` on empty collections (#15732)
  Improve the file watching failure error message (#15728)
  Speed symbol state merging back up (#15731)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant