www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10005] New: struct variable declaration and const-correctness

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

           Summary: struct variable declaration and const-correctness
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



In variable declaration, initializer should have a type that is implicitly
convertible to the required type, with the exception of the case that is an
unique expression.

But the rule is currently broken in struct object construction.
This code should raise errors in all declarations.

void main()
{
    static struct S
    {
        int[] a;
    }
    int[] marr = [1,2,3];
    immutable int[] iarr = [1,2,3];
    // mutable object should not be implicitly convertible to immutable
    immutable S i = S(marr);
    // immutable object should not be implicitly convertible to mutable
    S m = immutable S(iarr);

    static struct MS
    {
        int[] a;
        this(int n) { a = new int[](n); }
    }
    // mutable object should not be implicitly convertible to immutable
    immutable MS i = MS(3);

    static struct IS
    {
        int[] a;
        this(int n) immutable { a = new int[](n); }
    }
    // immutable object should not be implicitly convertible to mutable
    IS m = immutable IS(3);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 29 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10005


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/1948

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




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a7a1eb4f31efbe3e8fa4023c1a32486ffd49eb46
fix Issue 10005 - struct variable declaration and const-correctness

https://github.com/D-Programming-Language/dmd/commit/4ed3396c2cd6651695f07fc20c614a3e02701bc7


Issue 10005 - struct variable declaration and const-correctness

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 13 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10005


Walter Bright <bugzilla digitalmars.com> changed:

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


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