Bug 14057 – [REG2.066] opSlice not working correctly with AliasThis
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-27T04:02:00Z
Last change time
2015-02-18T03:41:37Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
jakobovrum
Comments
Comment #0 by jakobovrum — 2015-01-27T04:02:32Z
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.