[Issue 24321] New: 'need this' when accessing a mixin via an alias tuple
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jan 7 09:40:52 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24321
Issue ID: 24321
Summary: 'need this' when accessing a mixin via an alias tuple
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: maxsamukha at gmail.com
import std.meta;
struct Foo
{
int x;
}
mixin template Foo2()
{
int x;
}
struct S
{
Foo foo;
alias foos = AliasSeq!(foo);
mixin Foo2!() foo2;
alias foo2s = AliasSeq!(foo2);
}
void main()
{
S s;
auto x = s.foos[0].x; // ok
auto x2 = s.foo2s[0].x; // fail
}
a.d(26): Error: `this` is only defined in non-static member functions, not
`main`
a.d(26): Error: accessing non-static variable `x` requires an instance of `S`
--
More information about the Digitalmars-d-bugs
mailing list