[Issue 3345] Static and nonstatic methods with the same name should be allowed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 27 15:09:30 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=3345
--- Comment #6 from Alex <sascha.orlov at gmail.com> ---
struct S {
void opCall(int x) {
}
static S opCall(int x) {
return S.init;
}
}
int main() {
auto s = S(1);
s(1);
return 0;
}
yields:
source/app.d(13,15): Error: need `this` for `opCall` of type `void(int x)`
dmd failed with exit code 1.
whereas after interchanging the functions inside the struct:
struct S {
static S opCall(int x) {
return S.init;
}
void opCall(int x) {
}
}
int main() {
auto s = S(1);
s(1);
return 0;
}
yields:
source/app.d(13,15): Error: `app.S.opCall` called with argument types `(int)`
matches both:
source/app.d(3,14): `app.S.opCall(int x)`
and:
source/app.d(7,10): `app.S.opCall(int x)`
dmd failed with exit code 1.
At least on an Intel Mac 10.15.7.
--
More information about the Digitalmars-d-bugs
mailing list