www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Should ' disable this()' disable 'static opCall()'?

reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
I am thinking about opening a bug with the following code:

struct S
{
      disable this();

     static void opCall()
     {}
}

void main()
{}

Error: struct deneme.S static opCall is hidden by constructors and can 
never be called

Which seems to be due to the following change:

 
https://github.com/D-Programming-Language/dmd/commit/79ae211e71cf0937523010e39f7f0981e9550904

What do you think?

Ali
Jan 30 2015
parent reply "BBaz" <bb.temp gmx.com> writes:
On Friday, 30 January 2015 at 22:41:35 UTC, Ali Çehreli wrote:
 I am thinking about opening a bug with the following code:

 struct S
 {
      disable this();

     static void opCall()
     {}
 }

 void main()
 {}

 Error: struct deneme.S static opCall is hidden by constructors 
 and can never be called

 Which seems to be due to the following change:


 https://github.com/D-Programming-Language/dmd/commit/79ae211e71cf0937523010e39f7f0981e9550904

 What do you think?

 Ali
It should only be an error when static opCall() cant be distinguishable from this. --- struct S { disable this(); static string opCall(){return "yo mister White";} } void main() {} --- is distinguishable (by return type) but cant be compiled. You're right there's a problem.
Jan 30 2015
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/30/2015 03:19 PM, BBaz wrote:

 It should only be an error when static opCall() cant be distinguishable
 from this.

 ---
 struct S
 {
       disable this();
      static string opCall(){return "yo mister White";}
 }
 void main()
 {}
 ---

 is distinguishable (by return type) but cant be compiled.
I agree that this is a problem but return types are not parts of function signatures; so return types do not help "distinguish" functions. Besides, constructors don't have return types; so it is a little bit of a stretch to compare them to functions. :)
 You're right there's a problem.
Thank you. Filed: https://issues.dlang.org/show_bug.cgi?id=14087 Ali
Jan 30 2015
parent reply "BBaz" <bb.temp gmx.com> writes:
 "distinguish"
Yes, I know this a strange word. But it seems to be a valid one: http://www.collinsdictionary.com/dictionary/english/distinguish?showCookiePolicy=true "distinguishable" is ok as well.
Jan 30 2015
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/30/2015 04:30 PM, BBaz wrote:
 "distinguish"
Yes, I know this a strange word. But it seems to be a valid one: http://www.collinsdictionary.com/dictionary/english/distinguish?showCookiePolicy=true "distinguishable" is ok as well.
Sorry, I did not mean to emphasize "distinguish" over "distinguishable". I was quoting you as although I understood what you said, I am not used to hearing that word used in function matching. However, "match" does appear in the spec: :) http://dlang.org/function.html#function-overloading Ali
Jan 30 2015