www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5897] New: unrelated struct type casting should ignite construction

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5897

           Summary: unrelated struct type casting should ignite
                    construction
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



http://www.digitalmars.com/d/2.0/expression.html
 Casting a value v to a struct S, when value is not a struct of the same type,
is > equivalent to:

 S(v)
This spec explanation includes constructor call in D2, not only static opCall. But current dmd implementation is not. Following code compilation fails with -version=ctor. ---- struct A{ int n; } struct B{ int n, m; version(ctor) { this(A a){ n = a.n, m = a.n*2; } } else { static B opCall(A a) { B b; b.n = a.n, b.m = a.n*2; return b; } } } void main() { auto a = A(10); auto b = cast(B)a; assert(b.n == 10 && b.m == 20); } ---- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 27 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5897


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



Patch posted:
https://github.com/D-Programming-Language/dmd/pull/47

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 27 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5897


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



00:01:35 PDT ---
https://github.com/D-Programming-Language/dmd/commit/a0cbf6145dc6c726f40da1f118f851d57797e1bf

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