opDispatch bug?
Ali Çehreli
acehreli at yahoo.com
Sat Dec 15 10:07:57 PST 2012
On 12/15/2012 10:01 AM, Zhenya wrote:
> Hi!
> Is it a bug?
>
> class Foo
> {
> int m_bar;
> char m_gun;
> @property auto ref opDispatch(string s)()
> {
> return mixin("m_"~s);
> }
> this(int i,char c)
> {
> bar = i;//Error: undefined identifier bar, did you mean variable m_bar?
this.bar = i;
Because when it is simply bar, there is no indication that we are
talking about a member of this type. So, opDispatch() is not considered.
It could be the other way around as well, but personally I like the
current behaviour. Otherwise any type would go to opDispatch.
> this.gun = c;
> }
> }
Ali
More information about the Digitalmars-d-learn
mailing list