www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14780] New: Non-intuitive behavior for pointers to aggregates

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 puremagic.com
          Reporter: briancschott 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.

--
Jul 07 2015