Bug 23738 – A function accepting an alias of a type member requires static

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-02-24T15:26:17Z
Last change time
2023-02-24T15:32:35Z
Keywords
diagnostic, rejects-valid
Assigned to
No Owner
Creator
Steven Schveighoffer

Comments

Comment #0 by schveiguy — 2023-02-24T15:26:17Z
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/[email protected]
Comment #1 by snarwin+bugzilla — 2023-02-24T15:32:35Z
*** This issue has been marked as a duplicate of issue 17435 ***