Skip to content

Conversation

BobTheBuidler
Copy link
Contributor

@BobTheBuidler BobTheBuidler commented Sep 30, 2025

There is a bug in isinstance_native when one or more of the classes allows interpreted subclasses.

When interpreted subclasses are allowed, we cannot make any assumptions about the number of subclasses at compile time.

I'm not sure if this fix is better suited in all_concrete_classes

@BobTheBuidler BobTheBuidler changed the title [mypyc] fix: isinstance_native fast path conflict w/ subclasses [mypyc] fix: isinstance_native fast path conflict w/ interp. subclasses Sep 30, 2025
@p-sawicki
Copy link
Collaborator

p-sawicki commented Oct 1, 2025

I'm not sure if this fix is better suited in all_concrete_classes

i think it would make sense for all_concrete_classes to return None when any class in the hierarchy allows interpreted subclasses because that means that we can't find all the concrete classes.

Edit: though looking at the internals of all_concrete_classes this should already be the case.

i see there's one more use of all_concrete_classes to generate a type check that i think is affected by the same bug you're fixing.

could you also add an IR build test with code that hits this bug?

@BobTheBuidler
Copy link
Contributor Author

This is preventing me from updating one of my projects to 1.18, what would you say about cherry-picking this and the crash fix in #19960 to a 1.18.3?

@BobTheBuidler BobTheBuidler changed the title [mypyc] fix: isinstance_native fast path conflict w/ interp. subclasses [mypyc] fix: isinstance_native fast path conflict w/ interp. subclasses [1/1] Oct 1, 2025
@p-sawicki
Copy link
Collaborator

not sure if there's going to be a 1.18.3 since #19764 is closed but maybe you could suggest it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants