alias can't find symbol or can't use symbol
Carl Sturtivant via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Apr 29 17:17:37 PDT 2017
Consider the following.
struct member
{
int n;
}
struct outer
{
member x;
alias x this;
alias n2 = n;
}
This does not compile: alias n2 = n;
Error: undefined identifier 'n'
On the other hand if change that into
alias n2 = x.n;
then it does compile.
void main()
{
outer o;
o.n2 = 5;
}
Now this code doesn't compile: o.n2 = 5;
Error: need 'this' for 'n' of type 'int'
Given that one struct inside another is a static situation, this
seems unnecessarily strict. It's getting in the way of some name
management with `alias this`. What's the rationale here?
More information about the Digitalmars-d-learn
mailing list