Subject: | lookahead/lookbehind combined with \K in the same pattern causes compilation error |
The following script:
use Regexp::Debugger;
"" =~ m{
foo(?=foo)\K
}x;
fails with:
$VAR1 = {
'std_info' => {
'construct_type' => undef,
'regex_pos' => 0,
'construct' => '',
'depth' => 1,
'indent' => ' ',
'quantifier' => ''
},
'%+' => {
'construct' => '',
'start' => ''
}
};
$VAR1 = {
'std_info' => {
'indent' => ' ',
'quantifier' => '',
'construct_type' => undef,
'depth' => 2,
'construct' => '
',
'regex_pos' => 0
},
'%+' => {
'construct' => '
',
'whitespace' => '
',
'whitespace_chars' => '
'
}
};
$VAR1 = {
'%+' => {
'atom' => 'foo',
'construct' => 'foo',
'_self_matching' => 'foo'
},
'std_info' => {
'indent' => ' ',
'quantifier' => '',
'construct_type' => '_self_matching',
'regex_pos' => 1,
'construct' => 'foo',
'depth' => 2
}
};
$VAR1 = {
'std_info' => {
'indent' => ' ',
'quantifier' => '',
'construct_type' => undef,
'depth' => 2,
'regex_pos' => 4,
'construct' => '(?='
},
'%+' => {
'construct' => '(?=',
'lookaround_paren' => '(?='
}
};
$VAR1 = {
'std_info' => {
'indent' => ' ',
'quantifier' => '',
'construct_type' => '_self_matching',
'construct' => 'foo',
'regex_pos' => 7,
'depth' => 3
},
'%+' => {
'atom' => 'foo',
'construct' => 'foo',
'_self_matching' => 'foo'
}
};
$VAR1 = {
'%+' => {
'construct' => ')',
'closing_paren' => ')'
},
'std_info' => {
'quantifier' => '',
'indent' => ' ',
'regex_pos' => 10,
'construct' => ')',
'depth' => 3,
'construct_type' => undef
}
};
$VAR1 = {
'%+' => {
'construct' => '\\K',
'keep_marker' => '\\K'
},
'std_info' => {
'indent' => ' ',
'quantifier' => '',
'construct_type' => undef,
'depth' => 2,
'construct' => '\\K',
'regex_pos' => 11
}
};
$VAR1 = {
'%+' => {
'construct' => '
',
'whitespace' => '
',
'whitespace_chars' => '
'
},
'std_info' => {
'construct_type' => undef,
'construct' => '
',
'regex_pos' => 13,
'depth' => 2,
'indent' => ' ',
'quantifier' => ''
}
};
$VAR1 = {
'std_info' => {
'construct_type' => undef,
'depth' => 2,
'regex_pos' => 14,
'construct' => '',
'indent' => ' ',
'quantifier' => ''
},
'%+' => {
'construct' => '',
'end' => ''
}
};
\K not permitted in lookahead/lookbehind in regex; marked by <-- HERE in m/(?#R_d:0)(?>\A(?{Regexp::Debugger::_reset_debugger_state()})(?!)|\G(?{Regexp::Debugger::_reset_debugger_state_rematch()})(?!))|(?:(?{Regexp::Debugger::_report_event(0, 0, pos()); $^R})(?=)(?:(?>(?{local $Regexp::Debugger::prevpos=pos})
(?{
if (defined $Regexp::Debugger::prevpos && $Regexp::Debugger::prevpos < pos){
Regexp::Debugger::_report_event(0, 1, $Regexp::Debugger::prevpos);
Regexp::Debugger::_report_event(0, 1+1, pos());
}$^R })|(?{
Regexp::Debugger::_report_event(0, 1, pos());
$^R
})(?!))(?{Regexp::Debugger::_report_event(0, 3, pos()); $^R})(?=)foo(?{Regexp::Debugger::_report_event(0, 4, pos()); $^R})(?=)(?:(?{Regexp::Debugger::_report_event(0, 5, pos()); $^R})(?=)(?=(?{Regexp::Debugger::_report_event(0, 6, pos()); $^R})(?=)foo(?{Regexp::Debugger::_report_event(0, 7, pos()); $^R})(?=))(?{Regexp::Debugger::_report_event(0, 8, pos()); $^R})(?=))(?{Regexp::Debugger::_report_event(0, 10, pos()); $^R})(?=)\K <-- HERE (?{ local $Regexp::Grammars::match_start_pos = pos() })(?>(?{local $Regexp::Debugger::prevpos=pos})
(?{
if (defined $Regexp::Debugger::prevpos && $Regexp::Debugger::prevpos < pos){
Regexp::Debugger::_report_event(0, 11, $Regexp::Debugger::prevpos);
Regexp::Debugger::_report_event(0, 11+1, pos());
}$^R })|(?{
Regexp::Debugger::_report_event(0, 11, pos());
$^R
})(?!)))(?{Regexp::Debugger::_report_event(0, 13, pos()); $^R})(?=)|(?{Regexp::Debugger::_report_event(0, 14, pos()); $^R})(?=)(?!))/ at (eval 11) line 17.