Thread overview
[Issue 10005] New: struct variable declaration and const-correctness
Apr 29, 2013
Kenji Hara
Apr 29, 2013
Kenji Hara
May 14, 2013
Walter Bright
April 29, 2013
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


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-29 01:29:54 PDT ---
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: -------
April 29, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10005


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

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


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-29 03:39:33 PDT ---
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: -------
May 14, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10005



--- Comment #2 from github-bugzilla@puremagic.com 2013-05-13 17:52:14 PDT ---
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 Merge pull request #1948 from 9rnsr/fix10005

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 14, 2013
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: -------