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.
ref @property does not imply auto ref @property. My mistake.