Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve error reporting when proto is to blame.
  • Loading branch information
jnthn committed Jan 2, 2013
1 parent 799d759 commit bd41d2f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Perl6/Optimizer.pm
Expand Up @@ -182,7 +182,8 @@ class Perl6::Optimizer {
}
}
elsif $ct_result_proto == -1 || @ct_result_multi[0] == -1 {
self.report_innevitable_dispatch_failure($op, @types, @flags, $obj);
self.report_innevitable_dispatch_failure($op, @types, @flags, $obj,
:protoguilt($ct_result_proto == -1));
}
}

Expand Down Expand Up @@ -331,7 +332,7 @@ class Perl6::Optimizer {
[@types, @flags]
}

method report_innevitable_dispatch_failure($op, @types, @flags, $obj) {
method report_innevitable_dispatch_failure($op, @types, @flags, $obj, :$protoguilt) {
my @arg_names;
my $i := 0;
while $i < +@types {
Expand All @@ -343,11 +344,12 @@ class Perl6::Optimizer {
$i := $i + 1;
}
self.add_deadly($op,
"Calling '" ~ $obj.name ~ "' will never work with " ~
($protoguilt ?? "Calling proto of '" !! "Calling '") ~
$obj.name ~ "' will never work with " ~
(+@arg_names == 0 ??
"no arguments" !!
"argument types (" ~ nqp::join(', ', @arg_names) ~ ")"),
$obj.is_dispatcher ??
$obj.is_dispatcher && !$protoguilt ??
multi_sig_list($obj) !!
[" Expected: " ~ $obj.signature.perl]);
}
Expand Down

0 comments on commit bd41d2f

Please sign in to comment.