Thread overview
opDispatch bug?
Dec 15, 2012
Zhenya
Dec 15, 2012
Ali Çehreli
Dec 15, 2012
Ali Çehreli
Dec 15, 2012
Zhenya
December 15, 2012
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.gun = c;
	}
}
December 15, 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
December 15, 2012
On 12/15/2012 10:07 AM, Ali Çehreli wrote:

> Otherwise any type would go to opDispatch.

Wow. I made a typo in typo. :) That should be:

Otherwise any _typo_ would go to opDispatch.

Ali
December 15, 2012
On Saturday, 15 December 2012 at 18:09:00 UTC, Ali Çehreli wrote:
> On 12/15/2012 10:07 AM, Ali Çehreli wrote:
>
> > Otherwise any type would go to opDispatch.
>
> Wow. I made a typo in typo. :) That should be:
>
> Otherwise any _typo_ would go to opDispatch.
>
> Ali

It's pretty reasonable,thank you.