From b0a720cb6546c4fd85ff86b62ddd764f22ef8eec Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Mon, 20 Apr 2020 23:57:27 +0200 Subject: [PATCH] Specialize X::Method::NotFound for IterationEnd 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. --- src/core.c/Exception.pm6 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core.c/Exception.pm6 b/src/core.c/Exception.pm6 index f39f1dfadd4..800fc29da3b 100644 --- a/src/core.c/Exception.pm6 +++ b/src/core.c/Exception.pm6 @@ -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 {