[Issue 13574] incorrect code for assignment to dollar in slice expression

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Oct 6 06:26:03 PDT 2014


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, pull
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> ---
I think the "$' should be handled as an rvalue, therefoe $ should not be
assignable.

I think this is not only an issue for opDollar, but also for dynamic arrays.

void main()
{
    int[] arr = [1,2,3];
    auto x = arr[0 .. arr.length = 1];
    assert(arr.length == 1);
    auto y = arr[0 .. $ = 2];
    assert(arr.length != 2 && arr.length == 1); // pass
}

It's weird behavior, so I think all $ should not be assignable.


Compiler fix:
https://github.com/D-Programming-Language/dmd/pull/4045

--


More information about the Digitalmars-d-bugs mailing list