[Issue 12120] Static opCall for structures skipped (Github HEAD)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 9 17:30:34 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12120


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2014-02-09 17:30:31 PST ---
(In reply to comment #0)
> Here is the reduced code.
> 
> struct Foo {
>   this(int) {}
>   static Foo opCall() {
>     import std.stdio;
>     writeln("opCall");
>     Foo foo = Foo(0);
>     return foo;
>   }
> }
> 
> void main() {
>   Foo foo = Foo();
> }

If you define constructors in a struct, the syntax `Type()` should be reserved
for default construction.

If you want to support both Foo() and Foo(1), you should change the constructor
to static Foo opCall(int).

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