[Issue 13271] New: opDispatch fails without warning message if @property
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Aug 8 22:31:26 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13271
Issue ID: 13271
Summary: opDispatch fails without warning message if @property
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: vlevenfeld at gmail.com
struct Vector (uint length, Element = double)
{
ref @property component (string c)()
{
enum mat = q{xyzw};
enum col = q{rgba};
enum tex = q{uv};
static if (mat.canFind (c))
return components[mat.countUntil (c)];
else static if (col.canFind (c))
return components[col.countUntil (c)];
else static if (tex.canFind (c))
return components[tex.countUntil (c)];
else static assert (0);
}
ref @property opDispatch (string c)()
if (c.length == 1)
{
auto v = component!c;
pragma(msg, typeof(v)); // this outputs the expected result
return v; // so everything is fine, right? wrong...
}
Element[length] components;
}
If @property opDispatch is replaced with auto opDispatch then it works.
opDispatch should either work for properties or should give a more meaningful
error message than "Error: No property `x` for Vector" etc.
--
More information about the Digitalmars-d-bugs
mailing list