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

[WIP] Fix bugzilla 6082 - Constructors of templated types should be callabl… #16910

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dkorpel
Copy link
Contributor

@dkorpel dkorpel commented Oct 2, 2024

…e via IFTI

https://wiki.dlang.org/DIP40

This first version works for simple cases of a struct with a regular constructor, allowing Tuple(1, 2, 3) or Pair(1, 2), but some other cases not yet, like new Pair!byte(1, 2). Specifically it fails with:

  • Templated constructor functions
  • new expressions
  • Partial evaluation
  • classes
  • Structs without constructors

@dkorpel dkorpel added WIP Work In Progress - not ready for review or pulling Pending DIP Approval Needs Spec PR A PR updating the language specification needs to be submitted to dlang.org labels Oct 2, 2024
@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @dkorpel! 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

Auto-close Bugzilla Severity Description
6082 enhancement Constructors of templated types should be callable via IFTI

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#16910"

@dkorpel
Copy link
Contributor Author

dkorpel commented Oct 2, 2024

Interesting, there's now infinite recursion in std/container/array.d:599

this(T single) { __ctor!T(single); }

Edit: Calling a templated constructor would also trigger my new constructor rewrite, I added an extra check that it's actually an aggregate template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Spec PR A PR updating the language specification needs to be submitted to dlang.org Pending DIP Approval WIP Work In Progress - not ready for review or pulling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants