Skip to content

Commit

Permalink
Merge pull request #1868 from jsimonet/master
Browse files Browse the repository at this point in the history
Throws X::Multi::NoMatch if a proto routine is defined without multis.
  • Loading branch information
zoffixznet committed Aug 15, 2018
2 parents 22f779a + d0a8a7a commit eb8f608
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Perl6/Optimizer.nqp
Expand Up @@ -2531,11 +2531,14 @@ class Perl6::Optimizer {
%opts<protoguilt> := $protoguilt // nqp::p6bool(0);
%opts<arguments> := @arg_names;
%opts<objname> := $obj.name;
%opts<dispatcher> := $obj;
%opts<signature> := 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.
Expand Down
7 changes: 6 additions & 1 deletion t/05-messages/01-errors.t
Expand Up @@ -2,7 +2,7 @@ use lib <t/packages/>;
use Test;
use Test::Helpers;

plan 48;
plan 49;

# RT #129763
throws-like '1++', X::Multi::NoMatch,
Expand Down Expand Up @@ -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' },
Expand Down

0 comments on commit eb8f608

Please sign in to comment.