Bug 24013 – [REG 2.103.0] address of a __traits(getOverloads) item is not converted to a delegate anymore
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-06-25T07:41:54Z
Last change time
2023-07-02T13:41:43Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Basile-z
Comments
Comment #0 by b2.temp — 2023-06-25T07:41:54Z
## Description
Code used to compile and works until version 2.103.0
The problem seems to be that `&overload`, with `overload` coming from `__traits(getOverloads,...)` is not converted to a delegate anymore.
## Code
```
module reg2103;
import std.traits, std.meta;
alias GenericDescriptor = PropDescriptor!int;
struct PropDescriptor(T)
{
static if (!is(T == struct))
{
alias PropSetter = void delegate(T value);
alias PropGetter = T delegate();
}
else
{
alias PropSetter = void delegate(T value);
alias PropGetter = ref T delegate() return;
}
PropSetter _setter;
PropGetter _getter;
string _name;
void define(PropSetter aSetter, PropGetter aGetter, string aName)
{
setter(aSetter);
getter(aGetter);
}
void setter(PropSetter value)
{
_setter = value;
}
PropSetter setter(){return _setter;}
void getter(PropGetter value)
{
_getter = value;
}
PropGetter getter(){return _getter;}
void name(string value)
{
_name = value;
}
ref string name()
{
return _name;
}
}
enum Set;
enum Get;
mixin template PropertyPublisherImpl()
{
void*[] _publishedDescriptors;
void collectPublicationsFromPairs(T)()
{
foreach (member; __traits(derivedMembers, T))
foreach (overload; __traits(getOverloads, T, member))
{
alias Attributes = __traits(getAttributes, overload);
enum bool getterAttrib = staticIndexOf!(Get, Attributes) != -1;
enum bool setterAttrib = staticIndexOf!(Set, Attributes) != -1;
// define the getter
static if (getterAttrib)
{
alias Type = ReturnType!overload;
auto descriptor = new PropDescriptor!Type;
auto dg = &overload;
descriptor.define(descriptor.setter, dg, member);
}
}
}
}
void main()
{
class Bar
{
size_t _field;
mixin PropertyPublisherImpl;
this()
{
collectPublicationsFromPairs!Bar;
}
@Set void field(size_t aValue)
{
}
@Get size_t field()
{
return _field;
}
}
auto _ = new Bar;
}
```
Comment #1 by b2.temp — 2023-06-25T09:08:11Z
Fully nailed, problem is the type inferred for dg:
```
descriptor.define(descriptor.setter, &overload, member); // OK
auto dg = &overload;
descriptor.define(descriptor.setter, dg, member); // NG
```
@RazvanN7 created dlang/dmd pull request #15347 "Fix Issue 24013 - [REG 2.103.0] address of a __traits(getOverloads) item is not converted to a delegate anymore" fixing this issue:
- Fix Issue 24013 - [REG 2.103.0] address of a __traits(getOverloads) item is not converted to a delegate anymore
https://github.com/dlang/dmd/pull/15347
Comment #6 by dlang-bot — 2023-06-27T06:27:20Z
dlang/dmd pull request #15347 "Fix Issue 24013 - [REG 2.103.0] address of a __traits(getOverloads) item is not converted to a delegate anymore" was merged into stable:
- e63a24dc7c03133a8c5c63ac2d08e00bcd9ff736 by RazvanN7:
Fix Issue 24013 - [REG 2.103.0] address of a __traits(getOverloads) item is not converted to a delegate anymore
https://github.com/dlang/dmd/pull/15347
Comment #7 by dlang-bot — 2023-07-02T13:41:43Z
dlang/dmd pull request #15373 "merge stable" was merged into master:
- 5e1e97078faff33afbb999bc986ead7bdb0b2653 by Razvan Nitu:
Fix Issue 24013 - [REG 2.103.0] address of a __traits(getOverloads) item is not converted to a delegate anymore (#15347)
https://github.com/dlang/dmd/pull/15373