"alias foo this" compiles when "foo" is not defined
Stewart Gordon
smjg_1998 at yahoo.com
Fri Jun 26 17:03:24 PDT 2009
Jarrett Billingsley wrote:
> On Fri, Jun 26, 2009 at 5:54 PM, Ary Borenszweig<ary at esperanto.org.ar> wrote:
>> Is is ok that this compiles without errors?
>>
>> class Foo {
>> alias errorProne this;
>> }
Errors as expected on 1.042; compiles on 2.029.
> If I had to guess, it's only OK because the compiler probably doesn't
> actually look for the aliased symbol until you actually try to access
> something from it. But that does seem .. wrong.
It is wrong. Since this isn't in a template, the compiler should
perform semantic analysis on it in any case, and thus report an error.
But the really strange thing is that it doesn't complain about the
attempt to redefine 'this', which is a keyword.
This ought to be in Bugzilla if it isn't already and you can't find
anything in the spec that gives this form a meaning of its own.
Strangely, if I change 'this' to 'that', I get the expected
errorprone.d(2): Error: identifier 'errorProne' is not defined
Stewart.
More information about the Digitalmars-d-learn
mailing list