https://issues.dlang.org/show_bug.cgi?id=20233

--- Comment #6 from Steven Schveighoffer <[email protected]> ---
(In reply to Max Samukha from comment #5)
> 'alias this' is irrelevant. The original test case fails because the array's
> .ptr property is called as a function. See the example in my previous
> comment (there was a typo: "apply" -> "to apply").

Yes, original test case fails for a different reason, but alias this isn't
usable if you have opDispatch, which is definitely a bug I would think. It
should trickle down to alias this if opDispatch doesn't handle it.

e.g.:

-----

struct S
{
   int length;
}

struct T
{
   S s;
   alias s this;
   int opDispatch(string fn, Args...)(Args args) if(fn != "length")
   {
      return 5;
   }
}

void main()
{
   T t;
   import std.stdio;
   writeln(t.length);
}

-------

Error: no property length for type T

If you comment out opDispatch it works.

--

Reply via email to