Skip to content

Commit

Permalink
Panic when given empty character class
Browse files Browse the repository at this point in the history
  • Loading branch information
jstuder-gh committed Mar 23, 2018
1 parent 820c214 commit 7c41dfa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/QRegex/P6Regex/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,11 @@ class QRegex::P6Regex::Actions is HLL::Actions {
method assertion:sym<[>($/) {
my $clist := $<cclass_elem>;
my $qast := $clist[0].ast;
if +@($qast) == 0 {
$/.panic('Cannot have an empty character class. If you intended to include '
~ 'whitespace within this character class, escape it with \\'
);
}
if $qast.negate && $qast.rxtype eq 'subrule' {
$qast.subtype('zerowidth');
$qast := QAST::Regex.new(:rxtype<concat>, :node($/),
Expand Down

0 comments on commit 7c41dfa

Please sign in to comment.