Bug 24321 – 'need this' when accessing a mixin via an alias tuple

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-01-07T09:40:52Z
Last change time
2024-12-13T19:32:25Z
Assigned to
No Owner
Creator
Max Samukha
Moved to GitHub: dmd#18204 →

Comments

Comment #0 by maxsamukha — 2024-01-07T09:40:52Z
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`
Comment #1 by robert.schadek — 2024-12-13T19:32:25Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18204 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB