Compiler silently ignores some method overloads

Peter Häggman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 8 17:27:17 PDT 2016


On Sunday, 8 May 2016 at 13:28:47 UTC, pineapple wrote:
> [...]
> I get a compiler error like so:
>
>     E:\Dropbox\Projects\d\mach\sdl\surface.d(434): Error: none 
> of the overloads of 'opIndexAssign' are callable using argument 
> types (GLColor!float, int, int), candidates are:
>     E:\Dropbox\Projects\d\mach\sdl\surface.d(406):        
> mach.sdl.surface.Surface.opIndexAssign(const(uint) value, 
> const(int) x, const(int) y)
>
> Meaning the overloads using GLColor are apparently silently 
> ignored?

No they are not ignored, otherwise the following would not 
compile:

----
struct GLColor(T){T t0,t1,t2;}

struct Thing
{
     void opIndexAssign(T)(in GLColor!T color, in int x, in int 
y){}
     void opIndexAssign(T1, T2)(in GLColor!T1 color, in Vector2!T2 
vector){}
     void opIndexAssign(in uint value, in int x, in int y){}
}

void main(string[] args)
{
     Thing thing;
     thing[2,2] = GLColor!float(1, 1, 1);
}
----

Can you show your GLColor struct ? Maybe it contains an alias 
this or something else that mess the overload resolution.


More information about the Digitalmars-d-learn mailing list