Compiler silently ignores some method overloads
pineapple via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun May 8 06:28:47 PDT 2016
In my struct I have some methods with these signatures:
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)
And when I try to do this:
thing[2, 2] = GLColor!float(1, 1, 1);
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?
I had the same problem with another method. Here are my overloads:
void fill(in uint color)
void fill(T)(in GLColor!T color)
void fill(in ubyte r, in ubyte g, in ubyte b, in ubyte a =
255)
void fill(in Box!int box, in uint color)
void fill(T)(in Box!int box, in GLColor!T color)
void fill(in Box!int box, in ubyte r, in ubyte g, in ubyte b,
in ubyte a = 255)
void fill(in SDL_Rect* rect, in uint color)
And when I try to do this:
thing.fill(GLColor!float(1, 1, 1));
I get another compiler error:
E:\Dropbox\Projects\d\mach\sdl\surface.d(429): Error: none of
the overloads of 'fill' are callable using argument types
(GLColor!float), candidates are:
E:\Dropbox\Projects\d\mach\sdl\surface.d(179):
mach.sdl.surface.Surface.fill(const(uint) color)
E:\Dropbox\Projects\d\mach\sdl\surface.d(187):
mach.sdl.surface.Surface.fill(const(ubyte) r, const(ubyte) g,
const(ubyte) b, const(ubyte) a = cast(ubyte)255u)
E:\Dropbox\Projects\d\mach\sdl\surface.d(191):
mach.sdl.surface.Surface.fill(const(Box!int) box, const(uint)
color)
E:\Dropbox\Projects\d\mach\sdl\surface.d(199):
mach.sdl.surface.Surface.fill(const(Box!int) box, const(ubyte) r,
const(ubyte) g, const(ubyte) b, const(ubyte) a = cast(ubyte)255u)
E:\Dropbox\Projects\d\mach\sdl\surface.d(203):
mach.sdl.surface.Surface.fill(const(SDL_Rect*) rect, const(uint)
color)
The module containing the GLColor struct is definitely imported
correctly, and I don't see how this could be an issue with the
GLColor since its (admittedly meager) unittests all pass.
What am I missing?
More information about the Digitalmars-d-learn
mailing list