Skip to content

Commit

Permalink
Use the first placeholder AST to report placeholder method errors
Browse files Browse the repository at this point in the history
It would be nice to point to the first placeholder variable in use
when reporting an error with a placeholder, in order to give the user
more precise context
  • Loading branch information
hoelzro committed Oct 23, 2018
1 parent e8a3abc commit 04d7763
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Perl6/Actions.nqp
Expand Up @@ -4548,9 +4548,10 @@ class Perl6::Actions is HLL::Actions does STDActions {

my $non-placeholder-names := nqp::join(', ', @non-placeholder-names);

my $first-placeholder-name := $past.ann('placeholder_sig')[0]<placeholder>;
my $first-placeholder := $past.ann('placeholder_sig')[0];
my $first-placeholder-name := $first-placeholder<placeholder>;

$/.PRECURSOR.panic("Placeholder variables (eg. $first-placeholder-name) cannot be used in a method.\nPlease specify an explicit signature, like $*METHODTYPE $method-name ($non-placeholder-names) \{ ... \}");
$first-placeholder<ast>.PRECURSOR.panic("Placeholder variables (eg. $first-placeholder-name) cannot be used in a method.\nPlease specify an explicit signature, like $*METHODTYPE $method-name ($non-placeholder-names) \{ ... \}");
}
if is_clearly_returnless($past) {
$past[1] := QAST::Op.new(
Expand Down

0 comments on commit 04d7763

Please sign in to comment.