Bug 13271 – opDispatch fails without warning message if @property
Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-08-09T05:31:00Z
Last change time
2014-08-09T15:23:43Z
Assigned to
nobody
Creator
vlevenfeld
Comments
Comment #0 by vlevenfeld — 2014-08-09T05:31:26Z
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.
Comment #1 by vlevenfeld — 2014-08-09T15:23:43Z
ref @property does not imply auto ref @property.
My mistake.