[Issue 14780] New: Non-intuitive behavior for pointers to aggregates defining opSlice

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jul 7 02:56:52 PDT 2015


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

          Issue ID: 14780
           Summary: Non-intuitive behavior for pointers to aggregates
                    defining opSlice
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: briancschott at gmail.com

```
struct HasOpSlice
{
    int opSlice() { return 10; }
}

void main()
{
    HasOpSlice* pointer;
    int i = pointer[];
}
```

test.d(9): Error: need upper and lower bound to slice pointer

I'd like for this to Just Work(tm). I don't have any good ideas for how to make
this behave consistently in the case that there's an opSlice that takes two
arguments.

--


More information about the Digitalmars-d-bugs mailing list