www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4454] New: Can't implicitly cast static arrays of primitives to immutable

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

           Summary: Can't implicitly cast static arrays of primitives to
                    immutable
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com



Now that static arrays are value types, this should be legal because there's no
mutable indirection:

void main() {
    immutable uint[2] foo = getArray();
}

uint[2] getArray() {
    uint[2] ret;
    return ret;
}


It doesn't work on 2.047.  Instead I get:

Error: cannot implicitly convert expression (getArray()) of type uint[2u] to
const(immutable(uint)[])

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 13 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4454




Remove dependency to std.traits.

----
private template staticLength(tuple...)
{
    enum size_t staticLength = tuple.length;
}
template ReturnType(func...)
    if (staticLength!(func) == 1)    // (a)
{
    static if (is(typeof(func) R == return))
        alias R ReturnType;
    else
        static assert(0, "argument has no return type");
}

struct PointImpl(T)
{
     property auto test()
    {
        return PointImpl!int();
    }
}

struct Wrapper(T)
{
    T payload;

    auto test()
    {
        //pragma(msg, ReturnType!(T.test));
        //static if (is(ReturnType!(T.test))) { }
        static if (is(ReturnType!(T.test) == void)) { }
        return payload.test;
    }
}

Wrapper!(PointImpl!int) point;

void main()
{
    auto x = point.test;
}
----

A gagged forward reference error at (a) causes this problem.

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





[snip]



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


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

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



*** This issue has been marked as a duplicate of issue 8201 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 09 2012