Skip to content

Commit

Permalink
Add mention of 'sub' potentially missing
Browse files Browse the repository at this point in the history
In response to #4827  The
error message would now state:

    Variable '$verbose' is not declared.  Perhaps you forgot a 'sub' if
    this was intended to be part of a signature?
  • Loading branch information
lizmat committed Mar 23, 2022
1 parent 190e303 commit a56d239
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core.c/Exception.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -1174,9 +1174,13 @@ my class X::Undeclared does X::Comp {
my $message := "$.what '$.symbol' is not declared";
if +@.suggestions == 1 {
$message := "$message. Did you mean '@.suggestions[0]'?";
} elsif +@.suggestions > 1 {
}
elsif +@.suggestions > 1 {
$message := "$message. Did you mean any of these: { @.suggestions.map( { "'$_'" } ).join(", ") }?";
}
elsif $.what eq 'Variable' {
$message := "$message. Perhaps you forgot a 'sub' if this was intended to be part of a signature?";
}
$message.naive-word-wrapper
}
}
Expand Down

0 comments on commit a56d239

Please sign in to comment.