digitalmars.D.bugs - [Issue 14057] New: opSlice not working correctly with AliasThis
- via Digitalmars-d-bugs (36/36) Jan 26 2015 https://issues.dlang.org/show_bug.cgi?id=14057
https://issues.dlang.org/show_bug.cgi?id=14057 Issue ID: 14057 Summary: opSlice not working correctly with AliasThis Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: jakobovrum gmail.com The below code should work, but doesn't: --- struct Wrapper { int[] subType; alias subType this; Wrapper opSlice(size_t, size_t) { return this; } } void main() { auto w = Wrapper(); Wrapper w2 = w[0 .. 1337]; } --- test.d(15): Error: cannot implicitly convert expression (w.subType[0..1337]) of type int[] to Wrapper --- The subtype with slice capabilities seems to get priority. This also happens if the subtype is another struct with opSlice. --
Jan 26 2015