[Issue 12194] New: Constructor prevents static opCall regression?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 18 11:03:07 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12194
Summary: Constructor prevents static opCall regression?
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: regression
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: Jesse.K.Phillips+D at gmail.com
--- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D at gmail.com> 2014-02-18 11:02:49 PST ---
In 2.064 the following code worked as expected, with 2.065rc1 this fails to
compile with a hidden static opCall message. Structs can't have a default
constructor; is this approach deprecated in favor of the factory method?
I'd like to note that by removing the static opCall, the compilation succeeds
but runtime will fail; this of course means tracking down the places which need
fixed is not helped by the compiler.
void main() {
assert(Struct() == Struct(2));
}
struct Struct {
int a;
this(int a) {
this.a = a;
}
static Struct opCall() {
return Struct(2);
}
}
--------
test.d(10): Error: struct test.Struct static opCall is hidden by constructors
and can never be called
test.d(10): Please use a factory method instead, or replace all
constructors with static opCall.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list