Skip to content

Commit

Permalink
Specialize X::Method::NotFound for IterationEnd
Browse files Browse the repository at this point in the history
Even though IterationEnd is just an instantiated Mu, it is a special value
that occurs frequently in iterators.  This stumped me for about half an hour
until I figured that "of type 'Mu'" meant IterationEnd.

Also removed redundant $.private attribute default.
  • Loading branch information
lizmat committed Apr 20, 2020
1 parent 20ce556 commit b0a720c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/core.c/Exception.pm6
Expand Up @@ -158,12 +158,19 @@ my class X::Method::NotFound is Exception {
has Mu $.invocant;
has $.method;
has $.typename;
has Bool $.private = False;
has Bool $.private;
has $.addendum;

method of-type() {
nqp::eqaddr(nqp::decont($!invocant),IterationEnd)
?? "IterationEnd"
!! "of type '$.typename'"
}

method message() {
my $message = $.private
?? "No such private method '!$.method' for invocant of type '$.typename'"
!! "No such method '$.method' for invocant of type '$.typename'";
?? "No such private method '!$.method' for invocant $.of-type"
!! "No such method '$.method' for invocant $.of-type";

my %suggestions;
my int $max_length = do given $.method.chars {
Expand Down

0 comments on commit b0a720c

Please sign in to comment.