[WIP] Fix bugzilla 6082 - Constructors of templated types should be callabl…
…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
newexpressions- Partial evaluation
- classes
- Structs without constructors
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:andReturns:)
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"
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.