Skip to content

Commit

Permalink
Sort multi-dispatch fixes, to deal with a bug noted by pmichaud++.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Aug 4, 2011
1 parent 3823e80 commit c8eb6c4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/binder/multidispatch.c
Expand Up @@ -98,8 +98,10 @@ static INTVAL is_narrower(PARROT_INTERP, Rakudo_md_candidate_info *a, Rakudo_md_
return 0;

/* Otherwise, we see if one has a slurpy and the other not. A lack of
* slurpiness makes the candidate narrower. Otherwise, they're tied. */
return a->max_arity != SLURPY_ARITY && b->max_arity == SLURPY_ARITY;
* slurpiness makes the candidate narrower. Also narrower if the first
* needs a bind check and the second doesn't. Otherwise, they're tied. */
return (a->max_arity != SLURPY_ARITY && b->max_arity == SLURPY_ARITY) ||
(a->bind_check && !(b->bind_check));
}


Expand Down Expand Up @@ -406,7 +408,6 @@ static PMC* find_best_candidate(PARROT_INTERP, Rakudo_md_candidate_info **candid
* it right here. Flag that we've built a list of
* new possibles, and that this was not a pure
* type-based result that we can cache. */

if (!new_possibles)
new_possibles = mem_allocate_n_typed(num_candidates, Rakudo_md_candidate_info *);
pure_type_result = 0;
Expand Down Expand Up @@ -452,6 +453,14 @@ static PMC* find_best_candidate(PARROT_INTERP, Rakudo_md_candidate_info **candid
* a result we can cache on nominal type. */
pure_type_result = 0;
}

/* Otherwise, it's just nominal; accept it. */
else {
if (!new_possibles)
new_possibles = mem_allocate_n_typed(num_candidates, Rakudo_md_candidate_info *);
new_possibles[new_possibles_count] = possibles[i];
new_possibles_count++;
}
}

/* If we have an updated list of possibles, free old one and use this
Expand Down

0 comments on commit c8eb6c4

Please sign in to comment.