Skip to content

[ty] Fix subtyping of intersections containing newtypes of unions vs unions#24087

Merged
AlexWaygood merged 1 commit intomainfrom
alex-brent/newtype-subtyping
Mar 20, 2026
Merged

[ty] Fix subtyping of intersections containing newtypes of unions vs unions#24087
AlexWaygood merged 1 commit intomainfrom
alex-brent/newtype-subtyping

Conversation

@AlexWaygood
Copy link
Copy Markdown
Member

@AlexWaygood AlexWaygood commented Mar 20, 2026

Summary

We recognise a newtype as a subtype of its concrete base type, and we even recognise newtypes of unions as a subtype of their concrete base type, but we do not currently recognise intersections of newtypes of unions as subtypes of the newtype's concrete base type. This PR fixes that.

Fixes astral-sh/ty#2940

Co-authored-by: Brent Westbrook [email protected]

Test Plan

added mdtests that fail on main

@AlexWaygood AlexWaygood added bug Something isn't working ty Multi-file analysis & type inference labels Mar 20, 2026
@AlexWaygood AlexWaygood force-pushed the alex-brent/newtype-subtyping branch from f774ef8 to d02bfa6 Compare March 20, 2026 18:14
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Mar 20, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 85.29%. The percentage of expected errors that received a diagnostic held steady at 78.13%. The number of fully passing files held steady at 64/132.

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Mar 20, 2026

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Mar 20, 2026

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@AlexWaygood AlexWaygood enabled auto-merge (squash) March 20, 2026 18:22
@AlexWaygood AlexWaygood merged commit f32b9bb into main Mar 20, 2026
48 checks passed
@AlexWaygood AlexWaygood deleted the alex-brent/newtype-subtyping branch March 20, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Truthiness check narrows NewType(float) to TFloat & ~AlwaysFalsy, which is rejected as float

3 participants