August 26, 2014
https://issues.dlang.org/show_bug.cgi?id=11570

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to stevencoenen from comment #0)
> Following code generates an AssertError when executed.
> 
> class forward(T)
> {
>   void opDispatch(string s, T2)(T2 i)
>   {
>     import std.stdio;
>     writeln(s);
>   }
> }
> 
> void main()
> {
>   forward!(string) a;
>   a.foo(1);
> }

forward!(string) is a class type, so the variable 'a' in main is initialized to null by default. Then the class member function 'foo' is invoked on null class reference.

You have to initialize the variable 'a' by using allocated class object.

void main()
{
    forward!(string) a = new forward!(string)();
    a.foo(1);   // works
}

--