Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Start to improve multi-method dispatch failure errors. Now they inclu…
…de the method name and the type name, which is somewhat awesomer, but not yet awesome.
  • Loading branch information
jnthn committed Jul 16, 2010
1 parent c2ebda4 commit c80d2d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/glue/dispatch.pir
Expand Up @@ -116,7 +116,9 @@ a failure if there is none.
.local pmc exception
.get_results (exception)
pop_eh
if exception == "No candidates found to invoke" goto error
$S0 = exception
$S0 = substr $S0, 0, 29
if $S0 == "No candidates found to invoke" goto error
rethrow exception
error:
Expand Down Expand Up @@ -183,7 +185,9 @@ Implements the .* operator. Calls one or more matching methods.
.local pmc exception
.get_results (exception)
pop_eh
if exception == "No candidates found to invoke" goto it_loop
$S0 = exception
$S0 = substr $S0, 0, 29
if $S0 == "No candidates found to invoke" goto it_loop
rethrow exception
it_loop_end:
Expand Down
18 changes: 15 additions & 3 deletions src/pmc/p6invocation.pmc
Expand Up @@ -254,9 +254,21 @@ pmclass P6Invocation dynpmc group perl6_group auto_attrs {
PMC *ns;

/* Oh noes, no candidate. If we aren't in soft-fail mode, then
* throw an exception. */
if (!PObj_flag_TEST(P6I_FAILURE_MODE, SELF))
Parrot_ex_throw_from_c_args(interp, next, 1, "No candidates found to invoke");
* throw an exception with an informative error message. */
if (!PObj_flag_TEST(P6I_FAILURE_MODE, SELF)) {
STRING *method_name, *type_name;
PMC *WHAT, *perl_meth;
PMC *call_sig = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
PMC *obj = VTABLE_get_pmc_keyed_int(interp, call_sig, 0);
PMC *WHAT_meth = VTABLE_find_method(interp, obj, CONST_STRING(interp, "WHAT"));
Parrot_ext_call(interp, WHAT_meth, "Pi->P", obj, &WHAT);
perl_meth = VTABLE_find_method(interp, WHAT, CONST_STRING(interp, "perl"));
Parrot_ext_call(interp, perl_meth, "Pi->S", WHAT, &type_name);
GETATTR_P6Invocation_name(interp, SELF, method_name);
Parrot_ex_throw_from_c_args(interp, next, 1,
"No candidates found to invoke for method '%Ss' on object of type '%Ss'",
method_name, type_name);
}

/* Otherwise, we look up something that when invoked will just give a
* dispatch failure. */
Expand Down

0 comments on commit c80d2d9

Please sign in to comment.