Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

typed exceptions for if()

  • Loading branch information...
commit 9bbec9cb019cd55ba081b0f14df619bd70c3afab 1 parent 2566e75
@moritz moritz authored
Showing with 13 additions and 2 deletions.
  1. +4 −2 src/Perl6/Grammar.nqp
  2. +9 −0 src/core/Exception.pm
View
6 src/Perl6/Grammar.nqp
@@ -1434,8 +1434,10 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
if $m<ctx> eq '(' {
$/.CURSOR.'!clear_highwater'();
$/.CURSOR.'!cursor_pos'($m_pos);
- $/.CURSOR.sorry("Word '$_' interpreted as '$_" ~ "()' function call; please use whitespace " ~
- ($needparens ?? 'around the parens' !! 'instead of parens'));
+ $/.CURSOR.typed_sorry('X::Syntax::IfAsFunction',
+ word => $_,
+ :$needparens,
+ );
$/.CURSOR.'!cursor_pos'($pos);
$/.CURSOR.panic("Unexpected block in infix position (two terms in a row)");
}
View
9 src/core/Exception.pm
@@ -754,6 +754,15 @@ my class X::Syntax::UnlessElse does X::Syntax {
method message() { '"unless" does not take "else", please rewrite using "if"' }
}
+my class X::Syntax::IfAsFunction does X::Syntax {
+ has $.word;
+ has $.needparens;
+ method message {
+ "Word '$.word' interpreted as '{$.word}()' function call; please use whitespace "
+ ~ ($.needparens ?? 'around the parens' !! 'instead of parens')
+ }
+}
+
my class X::Syntax::Malformed::Elsif does X::Syntax {
has $.what = 'else if';
method message() { qq{In Perl 6, please use "elsif' instead of "$.what"} }
Please sign in to comment.
Something went wrong with that request. Please try again.