Issue 14087: @disable this hides static opCall

starcanopy starcanopy at protonmail.com
Mon Oct 26 02:40:01 UTC 2020


The OP gives the following example:

struct S
{
     @disable this();

     static void opCall()
     {}
}

The compiler will rebuke you: "Error: struct deneme.S static 
opCall is hidden by constructors and can never be called"

To Kenji and Walter, this is intended behavior, and the former is 
skeptical of such a pattern. But why? Denoting a function as 
@disable implies its use is verboten; it's obvious. Thus, if an 
opCall with no parameters is defined, would it not be logical 
that S() would fall to the aforementioned opCall? Is the 
ambiguity an issue? If so, why should it not be the choice of the 
developer to decide this?
Another method with which one may achieve this is renaming S to 
something else (e.g. SImpl), and then defining a factory function 
called S. It works, but it seems like extra work considering the 
method described in the issue.


More information about the Digitalmars-d mailing list