Bug 14087 – @disable this hides static opCall

Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-01-30T23:56:00Z
Last change time
2015-06-09T05:13:48Z
Assigned to
nobody
Creator
acehreli

Comments

Comment #0 by acehreli — 2015-01-30T23:56:05Z
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 by issues.dlang — 2015-01-31T06:05:20Z
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 by k.hara.pg — 2015-02-03T13:32:34Z
(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 by bugzilla — 2015-02-06T04:48:09Z
(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.