Skip to content

[mypyc] Fix vtable construction for deep trait inheritance#20917

Open
VaggelisD wants to merge 1 commit intopython:masterfrom
VaggelisD:vtable_trait
Open

[mypyc] Fix vtable construction for deep trait inheritance#20917
VaggelisD wants to merge 1 commit intopython:masterfrom
VaggelisD:vtable_trait

Conversation

@VaggelisD
Copy link
Contributor

@VaggelisD VaggelisD commented Feb 27, 2026

Fixes mypyc/mypyc#1189

The core issue: compute_vtable iterates cls.traits (direct parents only) instead of the full trait MRO, so when an intermediate trait is empty, grandparent trait methods are never added to the vtable.

The difference between cls.traits and all_traits for the issue's repro is the following:

Class Child
-----------

 - cls.traits:
    •  Middle  --> {}

 - all_traits:
    •  Child   --> {'derived': <FuncIR Child.derived>}
    •  Middle  --> {}
    •  Base    --> {'value': <FuncIR Base.value>}

@VaggelisD VaggelisD changed the title Fix vtable construction for deep trait inheritance [mypyc] Fix vtable construction for deep trait inheritance Feb 27, 2026
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.

Trait vtable computation misses methods from non-direct ancestor traits

1 participant