Skip to content

fix issue 21429 . Allow mixed-in opDispatch overloads #21444

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

Merged
merged 13 commits into from
Jul 8, 2025

Conversation

benjones
Copy link
Contributor

I think I've narrowed down the cause to the area I've edited. There is an overload set containing multiple opDispatch implementations. It think the next step is to resolve the correct on in the ??? block in typesem, but I'm not sure how best to do that. Would appreciate any suggestions there. The Issue also mentions issues with other op overloads, which I haven't looked at yet. I'd like to get something actually working for opDispatch before hunting that down.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @benjones! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#21444"

@benjones
Copy link
Contributor Author

It seems like rewriting the expression to e.opDispatch!ident and then running semantic on it to do the resolution would work? But I'm not sure which expression type to use there.

@benjones
Copy link
Contributor Author

@RazvanN7 or @dkorpel any suggestions here? You two seem to be the most knowledgeable about semantic stuff

@benjones benjones marked this pull request as ready for review June 19, 2025 04:16
@benjones
Copy link
Contributor Author

OK, I think I got this working for the issue I had. I'll investigate the other overloads like Steven mentioned and am happy for whatever other feedback folks have

@benjones
Copy link
Contributor Author

OK, opBinary left and right overloads are now included in the fix. I'm assuming similar fixes are needed for opBinaryAssign? Also, I'll look into simplifying the opDispatch logic now that I know that treating an OverloadSet as a TemplateDeclaration seems to work OK here.

@benjones benjones changed the title fix issue 21429 . Allow mixed-in opDispatch overloads (draft) fix issue 21429 . Allow mixed-in opDispatch overloads Jun 23, 2025
@dkorpel
Copy link
Contributor

dkorpel commented Jun 24, 2025

I'm not familiar with OverloadSet so I'd need to dig in the code a bit before I can say if this approach is right, but if it passes all tests that's a good sign. Operator overload resolution is special because it doesn't do UFCS, otherwise I don't think there are any differences with regular .method calls.

If you're going to fix the issue for all operator overloads, I suggest creating a common function used for all searching of opXXX functions to ensure consistency and making future changes easier.

@benjones
Copy link
Contributor Author

I'm about to wrap up a fix to opOpAssign. I'll see what similarities there are and what I can extract. I sort of feel like I'm playing whack-a-mole on where else there's an assumption that something is a template, not an overloadSet. Thanks for the feedback!

@benjones
Copy link
Contributor Author

Skimmed through opover.d and I didn't see any other places where there would be a similar "assume I get a single template from search_function, not an overload set" assumption/problem, so hopefully opDispatch, opBinary, and opOpAssign were the only places.

@benjones
Copy link
Contributor Author

@thewilsonator any idea who might be good to take a look at this?

@benjones
Copy link
Contributor Author

benjones commented Jul 7, 2025

Bump

Copy link
Contributor

@thewilsonator thewilsonator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I somehow missed this

@thewilsonator
Copy link
Contributor

Could you please rebase or force push to restart the CI

@thewilsonator thewilsonator merged commit 9610da2 into dlang:master Jul 8, 2025
44 checks passed
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.

mixin templates cannot produce opDispatch or opBinary overloads with multiple mixins
4 participants