[Issue 14236] New: opIndexUnary and opIndex fallback
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Mar 2 07:30:32 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14236
Issue ID: 14236
Summary: opIndexUnary and opIndex fallback
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: john.loughran.colvin at gmail.com
struct S
{
auto opIndex(size_t i)
{
return 1;
}
auto opIndexUnary(string s)(size_t i, size_t j)
{
return -1;
}
}
unittest
{
S s;
assert(-s[0] == -1);
}
this fails to compile because the compiler won't fall back to using opIndex
when it can't find an applicable opIndexUnary
--
More information about the Digitalmars-d-bugs
mailing list