[qfcc] Prefer fixed types over generic

This allows the various vector,vector and vector,scalar to disambiguate.
This commit is contained in:
Bill Currie 2025-01-13 17:47:52 +09:00
parent 027ad12c72
commit b28cd673ae

View file

@ -597,9 +597,13 @@ check_type (const type_t *type, callparm_t param, unsigned *cost, bool promote)
return false; return false;
} }
if (!type_promotes (type, param.type)) { if (!type_promotes (type, param.type)) {
return param.implicit && type_demotes (type, param.type); bool demotes = param.implicit && type_demotes (type, param.type);
if (demotes) {
*cost += 1;
}
return demotes;
} }
*cost += 1; *cost += 2;
return true; return true;
} }
@ -649,6 +653,7 @@ find_generic_function (genfunc_t **genfuncs, const expr_t *fexpr,
for (int i = 0; ok && i < num_params; i++) { for (int i = 0; ok && i < num_params; i++) {
auto p = &g->params[i]; auto p = &g->params[i];
if (!p->fixed_type) { if (!p->fixed_type) {
costs[j] += 1;
int ind = p->gentype; int ind = p->gentype;
if (!types[ind]) { if (!types[ind]) {
types[ind] = select_type (&g->types[ind], call_params[i]); types[ind] = select_type (&g->types[ind], call_params[i]);