Thread overview | ||||||
---|---|---|---|---|---|---|
|
June 26, 2009 "alias foo this" compiles when "foo" is not defined | ||||
---|---|---|---|---|
| ||||
Is is ok that this compiles without errors? class Foo { alias errorProne this; } |
June 26, 2009 Re: "alias foo this" compiles when "foo" is not defined | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ary Borenszweig | On Fri, Jun 26, 2009 at 5:54 PM, Ary Borenszweig<ary@esperanto.org.ar> wrote: > 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. |
June 27, 2009 Re: "alias foo this" compiles when "foo" is not defined | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: > On Fri, Jun 26, 2009 at 5:54 PM, Ary Borenszweig<ary@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. |
June 27, 2009 Re: "alias foo this" compiles when "foo" is not defined | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | Stewart Gordon escribió: > Jarrett Billingsley wrote: >> On Fri, Jun 26, 2009 at 5:54 PM, Ary Borenszweig<ary@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. 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. |
Copyright © 1999-2021 by the D Language Foundation