diff --git a/src/Perl6/Optimizer.nqp b/src/Perl6/Optimizer.nqp index 8b11bc6143d..d4b8dc213a0 100644 --- a/src/Perl6/Optimizer.nqp +++ b/src/Perl6/Optimizer.nqp @@ -2531,11 +2531,14 @@ class Perl6::Optimizer { %opts := $protoguilt // nqp::p6bool(0); %opts := @arg_names; %opts := $obj.name; + %opts := $obj; %opts := nqp::can($obj, 'is_dispatcher') && $obj.is_dispatcher && !$protoguilt ?? multi_sig_list($obj) !! [try $obj.signature.gist]; - - $!problems.add_exception(['X', 'TypeCheck', 'Argument'], $op, |%opts); + nqp::if( nqp::can($obj, 'is_dispatcher') && $obj.is_dispatcher && nqp::elems($obj.dispatchees) == 0, + $!problems.add_exception(['X', 'Multi', 'NoMatch'], $op, |%opts), + $!problems.add_exception(['X', 'TypeCheck', 'Argument'], $op, |%opts) + ); } # Signature list for multis. diff --git a/t/05-messages/01-errors.t b/t/05-messages/01-errors.t index c5084539abe..59c2b953f01 100644 --- a/t/05-messages/01-errors.t +++ b/t/05-messages/01-errors.t @@ -2,7 +2,7 @@ use lib ; use Test; use Test::Helpers; -plan 48; +plan 49; # RT #129763 throws-like '1++', X::Multi::NoMatch, @@ -198,6 +198,11 @@ throws-like { class { proto method x(|) {*} }.new.x }, X::Multi::NoMatch, :message{ .contains: 'only the proto' & none 'none of these signatures' }, 'error points out only only proto is defined'; +# GH #1746 +throws-like { EVAL 'proto x(|) {*}; x' }, X::Multi::NoMatch, + :message{ .contains: 'only the proto' & none 'none of these signatures' }, + 'error points out only only proto routine is defined'; + # RT #131367 throws-like { Blob.split }, X::Multi::NoMatch, :message{ .contains: 'only the proto' & none 'none of these signatures' },