Using one of the most recent revisions of AngelScript, one of our testers ran into a bug where the script was unable to pick the right overload for an enum type in the following circumstances:
enum e {val}
void f(int) {}
void f(int8) {}
void f(int16) {}
void f(int64) {}
void main() {
f(val);
}
Essentially, neither of the int overloads is preferred by enum types (although signed int is preferred over unsigned). This was problematic, because our scripting interface exposes a method with a number of similar overloads that would ideally support any enum type, including user-defined ones. I was somewhat familiar with the way overload resolution works after research for my other recent report, which let me identify a likely source of the problem. The file as_compiler.cpp contains the following lines (beginning at line 5723 in our revision):
else if( to.GetSizeInMemoryBytes() || ctx->type.dataType.GetSizeInMemoryBytes() )
cost = asCC_PRIMITIVE_SIZE_CONV;
I believe that the || operator in this part was actually intended to be !=, i.e. a size conversion is to be performed when two types differ in size. Modifying it seemingly fixed the issue on our side.