[Issue 14057] New: opSlice not working correctly with AliasThis
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jan 26 20:02:32 PST 2015
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 at puremagic.com
Reporter: jakobovrum at 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.
--
More information about the Digitalmars-d-bugs
mailing list