| Thread overview | |||||||
|---|---|---|---|---|---|---|---|
|
January 30, 2015 Should '@disable this()' disable 'static opCall()'? | ||||
|---|---|---|---|---|
| ||||
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
| ||||
January 30, 2015 Re: Should '@disable this()' disable 'static opCall()'? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | 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.
| |||
January 30, 2015 Re: Should '@disable this()' disable 'static opCall()'? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to BBaz | 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
| |||
January 31, 2015 Re: Should '@disable this()' disable 'static opCall()'? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | > "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. | |||
January 31, 2015 Re: Should '@disable this()' disable 'static opCall()'? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to BBaz | 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 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply