digitalmars.D.learn - "alias foo this" compiles when "foo" is not defined
- Ary Borenszweig (4/4) Jun 26 2009 Is is ok that this compiles without errors?
- Jarrett Billingsley (5/9) Jun 26 2009 If I had to guess, it's only OK because the compiler probably doesn't
- Stewart Gordon (11/20) Jun 26 2009 It is wrong. Since this isn't in a template, the compiler should
- Ary Borenszweig (5/25) Jun 26 2009 It's called "alias this", that's not the problem:
Is is ok that this compiles without errors? class Foo { alias errorProne this; }
Jun 26 2009
On Fri, Jun 26, 2009 at 5:54 PM, Ary Borenszweig<ary esperanto.org.ar> wrot= e:Is is ok that this compiles without errors? class Foo { =A0 =A0 =A0 =A0alias errorProne this; }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.
Jun 26 2009
Jarrett Billingsley wrote:On Fri, Jun 26, 2009 at 5:54 PM, Ary Borenszweig<ary esperanto.org.ar> wrote:Errors as expected on 1.042; compiles on 2.029.Is is ok that this compiles without errors? class Foo { alias errorProne this; }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.
Jun 26 2009
Stewart Gordon escribió:Jarrett Billingsley wrote:It's called "alias this", that's not the problem: http://digitalmars.com/d/2.0/class.html#AliasThis I also think it should complain, because it makes no sense to just leave it there, unresolved.On Fri, Jun 26, 2009 at 5:54 PM, Ary Borenszweig<ary esperanto.org.ar> wrote:Errors as expected on 1.042; compiles on 2.029.Is is ok that this compiles without errors? class Foo { alias errorProne this; }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.
Jun 26 2009