Skip to content

Commit

Permalink
Forbid null operators.
Browse files Browse the repository at this point in the history
Adds a typed exception for them also.
  • Loading branch information
jnthn committed Mar 8, 2013
1 parent 085f746 commit f27a139
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Perl6/Grammar.pm
Expand Up @@ -3402,6 +3402,11 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
method add_categorical($category, $opname, $canname, $subname, $declarand?) {
my $self := self;

# Ensure it's not a null name.
if $opname eq '' {
self.typed_panic('X::Syntax::Extension::Null');
}

# If we already have the required operator in the grammar, just return.
if nqp::can(self, $canname) {
return 1;
Expand Down
6 changes: 6 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -842,6 +842,12 @@ my class X::Syntax::Extension::Category does X::Syntax {
}
}

my class X::Syntax::Extension::Null does X::Syntax {
method message() {
"Null operator is not allowed";
}
}

my class X::Syntax::InfixInTermPosition does X::Syntax {
has $.infix;
method message() {
Expand Down

0 comments on commit f27a139

Please sign in to comment.