Function overloading does not work with multiset
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=7812
Reported by Karl Gustav Sterneberg kg@roxen.com
I have the following scenario with an overloaded function with one function taking a multiset of PagePath and one function taking a multiset of IssuePath. When calling the function add with a multiset containing a PagePath, the add(multiset(IssuePath) is entered and not add(multiset(PagePath) as expected.
Example:
int main(int argc, array(string) argv)
{
PathContainer pc = PathContainer();
multiset(PagePath) page_paths = (<>);
PagePath page_path = PagePath("my-prefix", "2016-10-25 13:23:34", "my-id");
page_paths[page_path] = 1;
pc.add(page_paths);
return 0;
}
class PathContainer {
// Some code...
variant void add(multiset(PagePath) page_paths) {
werror("Adding page paths\n");
this::page_paths = this::page_paths | page_paths;
}
variant void add(multiset(IssuePath) issue_paths) {
werror("Adding issue paths\n");
this::issue_paths = this::issue_paths | issue_paths;
}
// More code...
}
When running this:
pike variant-test.pike Adding issue paths
Wrong function is called!
See attached file for complete example!