Skip to content

Commit

Permalink
fail with a good error on non-identifier after sub
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Masak committed Jan 19, 2015
1 parent 662d9bf commit d8f72bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/_007/Parser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Parser {
}
token statement:block { <block> }
rule statement:sub {
sub <identifier>
sub [<identifier> || <.panic "identifier">]
:my $*insub = True;
{
my $symbol = $<identifier>.Str;
Expand Down
13 changes: 13 additions & 0 deletions t/syntax/errors.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use v6;
use Test;
use _007::Test;

{
my $program = q:to/./;
sub !() {}
.

parse-error $program, X::Syntax::Missing, "must have a valid identifier after `sub`";
}

done;

0 comments on commit d8f72bf

Please sign in to comment.