Skip to content

Commit

Permalink
throw typed exception for non-associative operators
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Dec 30, 2012
1 parent 7d3e01f commit 13e8052
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Perl6/Grammar.pm
Expand Up @@ -239,6 +239,10 @@ role STD {
self.typed_panic('X::Comp::NYI', :$feature)
}

method EXPR_nonassoc($cur, $left, $right) {
self.typed_panic('X::Syntax::NonAssociative', :left(~$left), :right(~$right));
}

# "when" arg assumes more things will become obsolete after Perl 6 comes out...
method obs($old, $new, $when = 'in Perl 6') {
$*W.throw(self.MATCH(), ['X', 'Obsolete'],
Expand Down
8 changes: 8 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -765,6 +765,14 @@ my class X::Syntax::Number::RadixOutOfRange does X::Syntax {
method message() { "Radix $.radix out of range (allowed: 2..36)" }
}

my class X::Syntax::NonAssociative does X::Syntax {
has $.left;
has $.right;
method message() {
"Operators '$.left' and '$.right' are non-associtiave and require parenthesis";
}
}

my class X::Syntax::Regex::Adverb does X::Syntax {
has $.adverb;
has $.construct;
Expand Down

0 comments on commit 13e8052

Please sign in to comment.