Bug 6479 – spurious alias this with struct and mixin template
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-08-12T12:22:00Z
Last change time
2011-11-15T12:08:30Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
hoganmeier
Comments
Comment #0 by hoganmeier — 2011-08-12T12:22:30Z
struct Memory
{
mixin Wrapper!();
}
struct Image
{
Memory sup;
alias sup this;
}
mixin template Wrapper()
{
}
$ dmd -c test.d
DMD v2.054 DEBUG
test.d(8): Error: alias this there can be only one alias this
As soon as the template precedes Image, it works.
In my real code this is all spread among different modules, so it also is an order of compilation dependent issue.
Comment #1 by hoganmeier — 2011-08-12T12:26:12Z
Well, forget the last half sentence ;)
btw, I probably would never have figured this out without DustMite :)
Comment #2 by k.hara.pg — 2011-10-23T04:58:07Z
This is a bug related to forward reference.
struct Memory
{
mixin Wrapper!();
}
//mixin template Wrapper() {} // OK
struct Image
{
Memory sup;
alias sup this;
}
mixin template Wrapper() {} // NG
Comment #3 by k.hara.pg — 2011-10-23T07:01:08Z
https://github.com/D-Programming-Language/dmd/pull/471
This patch does not solve forward reference order problem, and has an issue.
struct S
{
int value;
alias value this;
alias value this; // alias this forwards to same symbol is allowed
}
But I think this is acceptable issue.
Comment #4 by hoganmeier — 2011-10-23T07:45:38Z
(In reply to comment #2)
> This is a bug related to forward reference.
>
> struct Memory
> {
> mixin Wrapper!();
> }
> //mixin template Wrapper() {} // OK
> struct Image
> {
> Memory sup;
> alias sup this;
> }
> mixin template Wrapper() {} // NG
Well as I said, the code is spread over several modules.
So it's hard to make sure Wrapper is processed first.
Comment #5 by hoganmeier — 2011-11-11T09:12:29Z
btw, now it tells
Error: alias this test.Image.__anonymous there can be only one alias this