October 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6036



--- Comment #11 from bearophile_hugs@eml.cc 2012-10-06 11:08:35 PDT ---
(In reply to comment #5)

> struct Adder {
>     int v;
>     auto opCall(int x) { return x + v; }
> }
> 
> auto adder(int v) {
>     return Adder(v);  // How do I call the constructor??
> }
> 
> int main() {
>     auto a = adder(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?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6036



--- Comment #12 from Kenji Hara <k.hara.pg@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: -------
October 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6036


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |szadows@gmail.com


--- Comment #13 from Kenji Hara <k.hara.pg@gmail.com> 2012-10-06 16:44:29 PDT ---
*** Issue 7210 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 07, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6036



--- Comment #14 from bearophile_hugs@eml.cc 2012-10-07 05:51:58 PDT ---
(In reply to comment #12)

> 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.

See a discussion thread: http://forum.dlang.org/thread/rwypxtvosdhjiwrtzwfi@forum.dlang.org

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 07, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6036


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |FIXED


--- Comment #15 from yebblies <yebblies@gmail.com> 2012-10-08 05:46:35 EST ---
https://github.com/D-Programming-Language/dmd/commit/098096c3b38f1cd0e8feb41caebbbb2f0f59b8fe

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 03, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6036


Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow@gmail.com


--- Comment #16 from Vladimir Panteleev <thecybershadow@gmail.com> 2013-04-03 08:12:53 EEST ---
There is still a problem with the default constructor (a non-static opCall is chosen instead of it), see Issue 9078.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
1 2
Next ›   Last »