-
-
Notifications
You must be signed in to change notification settings - Fork 701
extern(C++) opBinary error with getOverloads #22819
Copy link
Copy link
Open
Description
extern(C++) struct S
{
int opBinary(string op)(S rhs) if (op == "+")
{
return 0;
}
int opBinary(string op)(int rhs) if (op == "+")
{
return 0;
}
int opBinary(string op)(int rhs) if (op == "-")
{
return 0;
}
}
size_t test()
{
size_t count;
static foreach (overload; __traits(getOverloads, S, "opBinary", true))
static foreach(op; ["+", "-"])
static if (__traits(compiles, overload!op))
{
cast(void)&overload!op;
pragma(msg, "op=", op, " ", typeof(&overload!op));
count++;
}
return count;
}
static assert(test() == 3);DMD generates the following error:
testopbinary.d(21): Error: template instance `testopbinarymangle.S.overload!"+"` internal compiler error: C++ `string` template value parameter is not supported
static if (__traits(compiles, overload!op))
^
The problem is that DMD uses the name "overload" instead of "opBinary" when checking for operator overloading during mangling of extern(C++).
I will make a PR.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels