Skip to content

Commit 2b61433

Browse files
committed
Make !LITERAL cope with type objects.
1 parent 18f7ec6 commit 2b61433

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/QRegex/Cursor.nqp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -502,20 +502,25 @@ role NQPCursorRole is export {
502502
$cur;
503503
}
504504

505-
method !LITERAL(str $str, int $i = 0) {
506-
my $cur;
507-
my int $litlen := nqp::chars($str);
508-
my str $target := nqp::getattr_s($!shared, ParseShared, '$!target');
509-
if $litlen < 1 ||
510-
($i ?? nqp::lc(nqp::substr($target, $!pos, $litlen)) eq nqp::lc($str)
511-
!! nqp::substr($target, $!pos, $litlen) eq $str) {
512-
$cur := self."!cursor_start_cur"();
513-
$cur."!cursor_pass"($!pos + $litlen);
505+
method !LITERAL($strish, int $i = 0) {
506+
if nqp::isconcrete($strish) {
507+
my str $str := $strish;
508+
my int $litlen := nqp::chars($str);
509+
my str $target := nqp::getattr_s($!shared, ParseShared, '$!target');
510+
if $litlen < 1 ||
511+
($i ?? nqp::lc(nqp::substr($target, $!pos, $litlen)) eq nqp::lc($str)
512+
!! nqp::substr($target, $!pos, $litlen) eq $str) {
513+
my $cur := self."!cursor_start_cur"();
514+
$cur."!cursor_pass"($!pos + $litlen);
515+
$cur
516+
}
517+
else {
518+
nqp::getattr($!shared, ParseShared, '$!fail_cursor');
519+
}
514520
}
515521
else {
516-
$cur := nqp::getattr($!shared, ParseShared, '$!fail_cursor');
522+
nqp::getattr($!shared, ParseShared, '$!fail_cursor');
517523
}
518-
$cur;
519524
}
520525

521526
method !DYNQUANT_LIMITS($mm) {

0 commit comments

Comments
 (0)