[Issue 23738] New: A function accepting an alias of a type member requires static
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 24 15:26:17 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23738
Issue ID: 23738
Summary: A function accepting an alias of a type member
requires static
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: diagnostic, rejects-valid
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: schveiguy at gmail.com
Consider the following complete file:
```d
struct S
{
int t;
}
static void foo(alias F)()
{
}
void bar(alias F)()
{
}
void main()
{
foo!(S.t);
bar!(S.t); // Error: need `this` for `bar` of type `pure nothrow @nogc
@safe void()`
}
```
The call to `foo` succeeds, whereas the call to `bar` fails. The `static`
storage class for a function at module level should be a no-op, but somehow
it's affecting compilation. I believe both should succeed (taking an alias to a
member without actually using the member, e.g. for introspection, is valid),
though it's also worth investigating why `static` affects this function.
See relevant thread, apparently an unreported bug since 2013:
https://forum.dlang.org/post/simvgcbylmisvdlilxev@forum.dlang.org
--
More information about the Digitalmars-d-bugs
mailing list