D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14087 - @disable this hides static opCall
Summary: @disable this hides static opCall
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-30 23:56 UTC by Ali Cehreli
Modified: 2015-06-09 05:13 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ali Cehreli 2015-01-30 23:56:05 UTC
This seems to be a regression due to the following change:

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

struct S
{
    @disable this();

    static void opCall()
    {}
}

void main()
{}

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

It doesn't seem right to me that a disabled constructor hides opCall.

Ali
Comment 1 Jonathan M Davis 2015-01-31 06:05:20 UTC
Yeah. That sounds like a bug. static opCall isn't a constructor. At most, it's a factory function, and it doesn't even have to be that (e.g. LocalTime and UTC in std.datetime use it as the function to get at their singeltons - they're classes though, not structs, and don't @disable this).
Comment 2 Kenji Hara 2015-02-03 13:32:34 UTC
(In reply to Ali Cehreli from comment #0)
> This seems to be a regression due to the following change:
> 
> https://github.com/D-Programming-Language/dmd/commit/
> 79ae211e71cf0937523010e39f7f0981e9550904
> 
> struct S
> {
>     @disable this();
> 
>     static void opCall()
>     {}
> }
> 
> void main()
> {}
> 
> Error: struct deneme.S static opCall is hidden by constructors and can never
> be called
> 
> It doesn't seem right to me that a disabled constructor hides opCall.

It's intended behavior.

With the expression S(), is it a default construction (but it's @disable-d), or a call of static opCall()? They conflicts each other.

Therefore compiler raises an error for the struct declaration.
Comment 3 Walter Bright 2015-02-06 04:48:09 UTC
(In reply to Kenji Hara from comment #2)
> Therefore compiler raises an error for the struct declaration.

I agree. Such code looks pretty dubious anyway, I'm good with it being an error.