Skip to content

Commit

Permalink
Fix bug with iteration of empty character class
Browse files Browse the repository at this point in the history
Check that there is at least one character class before applying the
regex nodes.

When compiling the 'conj' regex node, it expects to be able to shift
off at least one child node and iterates past the end as a result.

Fixes [Rakudo Issue #1622](rakudo/rakudo#1622)
  • Loading branch information
jstuder-gh committed Mar 30, 2018
1 parent b73a9b6 commit ab5dec0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/QRegex/P6Regex/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,8 @@ class QRegex::P6Regex::Actions is HLL::Actions {
@alts.push(QAST::Regex.new( $str, :rxtype<enumcharlist>, :node($/), :negate( $<sign> eq '-' ),
:subtype($RXm ?? 'ignoremark' !! '') ))
if nqp::chars($str);
$qast := +@alts == 1 ?? @alts[0] !!
$<sign> eq '-' ??
$qast := ( my $num := +@alts ) == 1 ?? @alts[0] !!
0 < $num && $<sign> eq '-' ??
QAST::Regex.new( :rxtype<concat>, :node($/), :negate(1),
QAST::Regex.new( :rxtype<conj>, :subtype<zerowidth>, |@alts ),
QAST::Regex.new( :rxtype<cclass>, :name<.> ) ) !!
Expand Down

0 comments on commit ab5dec0

Please sign in to comment.