[Issue 21881] Array operation fails to compile even though it really should

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 30 00:45:40 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21881

Blatnik <blatblatnik at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Array operation fails to    |Array operation fails to
                   |compile even though it      |compile even though it
                   |really shouldn'             |really should

--- Comment #1 from Blatnik <blatblatnik at gmail.com> ---
float[3] add42(float[3] a)
{
    return a[] + 42;
}

Fails to compile with "Error: array operation `a[] + cast(float)3` without
destination memory not allowed."

But

float[3] add42(float[3] a)
{
    float[3] result = a[] + 42;
    return result;
}

compiles just fine. I'm not sure if this is a bug, but if it was intended, I
don't see a reason why we couldn't do that.

--


More information about the Digitalmars-d-bugs mailing list