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

Fix object construction when some construction signatures would select a nontrivial __new__ and others a nontrivial __init__ #861

Closed
wants to merge 1 commit into from

Conversation

oremanj
Copy link
Contributor

@oremanj oremanj commented Jan 15, 2025

This previously fooled the vectorcall shortcut constructor; now we detect the conflict and disable vectorcall construction.

While we're here, update the complex call dispatcher to consider the constructor-ness of each overload independently, and make "overloads differ in constructor-ness" a reason to use the complex dispatcher. An actual object constructor that takes a T* self argument would have is_constructor = true, while a stub constructor that takes a nb::handle self argument (such as the one emitted by nb::new_) has is_constructor = false; these can be in the same overload set.

…t a nontrivial __new__ and others a nontrivial __init__

This previously fooled the vectorcall shortcut constructor; now we detect the conflict and disable vectorcall construction.

While we're here, update the complex call dispatcher to consider the constructor-ness of each overload independently, and make "overloads differ in constructor-ness" a reason to use the complex dispatcher. An actual object constructor that takes a `T*` self argument would have `is_constructor = true`, while a stub constructor that takes a `nb::handle` self argument (such as the one emitted by `nb::new_`) has `is_constructor = false`; these can be in the same overload set.
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.

1 participant