[Issue 22200] New: it is not specified that `$` yield a rvalue

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 11 08:26:38 UTC 2021


          Issue ID: 22200
           Summary: it is not specified that `$` yield a rvalue
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

I was curious to see if the following

void main()
    int[] a;
    a[++$ - 1] = 0;

worked. It is not

> /tmp/temp_7F0644F44CF0.d:8:9: Error: cannot modify operator `$`

but given the specifications

> the spec is "Within the [ ] of a static or a dynamic array, the symbol $ represents the length of the array."

it was not clear that this will fail.


More information about the Digitalmars-d-bugs mailing list