Skip to content

Commit

Permalink
Improve tipping logic for self."!private"()
Browse files Browse the repository at this point in the history
Don't suggest `self!"private"()` if no private candidates found.
  • Loading branch information
vrurg committed Jul 23, 2020
1 parent b36afcb commit 760034e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core.c/Exception.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ my class X::Method::NotFound is Exception {
my @tips;
my $indirect-method = "";

if $.method.starts-with("!") && !$.private {
$indirect-method = $.method.substr(1);
@tips.push: "Method name starts with '!', did you mean 'self!\"$indirect-method\"()'?";
}

my %suggestions;
my int $max_length = do given $.method.chars {
when 0..3 { 1 }
Expand Down Expand Up @@ -220,6 +215,11 @@ my class X::Method::NotFound is Exception {
}
}

if $.method.starts-with("!") && !$.private && $private_suggested {
$indirect-method = $.method.substr(1);
@tips.push: "Method name starts with '!', did you mean 'self!\"$indirect-method\"()'?";
}

if +%suggestions == 1 {
@tips.push: "Did you mean '%suggestions.keys()'?";
}
Expand Down

0 comments on commit 760034e

Please sign in to comment.