Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Apparent subscript will be treated as regex
Throw the same warning as STD does for things like
@var[0], $var{a} and $var<a> in regexes.
  • Loading branch information
FROGGS committed Feb 16, 2013
1 parent 1e85ffd commit 932bc53
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Perl6/Grammar.pm
Expand Up @@ -3770,8 +3770,14 @@ grammar Perl6::RegexGrammar is QRegex::P6Regex::Grammar does STD {
}

token metachar:sym<rakvar> {
<?before <sigil> [<alpha> | \W<alpha> | '(']> <var=.LANG('MAIN', 'variable')>
{ self.check_variable($<var>) }
<?before <sigil> $<twigil>=[<alpha> | \W<alpha> | '(']>
<var=.LANG('MAIN', 'variable')>
[
|| $<binding> = ( \s* '=' \s* <quantified_atom> )
{ self.check_variable($<var>) unless $<twigil> eq '<' }
|| { self.check_variable($<var>) }
[ <?before '.'? <[ \[ \{ \< ]>> <.worry: "Apparent subscript will be treated as regex"> ]?
]
}

token metachar:sym<qw> {
Expand Down

0 comments on commit 932bc53

Please sign in to comment.