[Issue 6036] Constructor, static opCall and object opCall

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Oct 6 16:53:59 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6036



--- Comment #12 from Kenji Hara <k.hara.pg at gmail.com> 2012-10-06 16:42:01 PDT ---
(In reply to comment #11)
> (In reply to comment #5)
> 
> A little reduced:
> 
> struct Adder {
>     int v;
>     int opCall(int x) { return x + v; }
> }
> void main() {
>     auto a = Adder(5);
> }
> 
> 
> It gives:
> 
> temp.d(6): Error: need 'this' for opCall type int(int x)
> 
> Is it expected that the instance opCall disables the implicitly created struct
> ctor?

At least it is same as before merging my pull, except small error message
difference.
It is still a corner case of language spec, but I think it is an expected
behavior.
Because, the operator overloading mechanism just consider whether the function
named opXXXX exists or not, and doesn't consider whether the opXXXX is really
static or not.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list