Skip Menu |
Report information
Id: 129299
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: smls75 [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: regex
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [REGEX] Quantified capture group breaks `$/.list`
Download (untitled) / with headers
text/plain 583b
When a quantified capture group matched zero times but the overall regex matches, then the List returned from `$/.list` stops iterating before the corresponding element: "ac" ~~ / (a) (b)? (c) /; say ($0, $1, $2); # (「a」 Nil 「c」) say $/.list; # (「a」) say $/.list.map({1}); # (1) say $/.list.elems; # 3 say $/.list[0, 1, 2, 3]; # (「a」 (Mu) 「c」 Nil Expected behavior would be for `$/.list;` to return `(「a」 Nil 「c」)`. mst++ suggested that maybe an InterationEnd is ending up where it shouldn't be.
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Subject: Re: [perl #129299] [REGEX] Quantified capture group breaks `$/.list`
Date: Sun, 18 Sep 2016 22:48:56 +0200
To: "Sam S. (via RT)" <perl6-bugs-followup [...] perl.org>
Download (untitled) / with headers
text/plain 1.1k
I’m looking into this. This appears to be an artefact of .gist on the list, caused by the say. Which also happens for .perl on the list. say $/.list.Str; # a c Suspecting the gistseen/perlseen machinery now. Investigating... Show quoted text
> On 18 Sep 2016, at 19:30, Sam S. (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Sam S. > # Please include the string: [perl #129299] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=129299 > > > > When a quantified capture group matched zero times but the overall regex matches, then the List returned from `$/.list` stops iterating before the corresponding element: > > "ac" ~~ / (a) (b)? (c) /; > say ($0, $1, $2); # (「a」 Nil 「c」) > say $/.list; # (「a」) > say $/.list.map({1}); # (1) > say $/.list.elems; # 3 > say $/.list[0, 1, 2, 3]; # (「a」 (Mu) 「c」 Nil > > Expected behavior would be for `$/.list;` to return `(「a」 Nil 「c」)`. > > mst++ suggested that maybe an InterationEnd is ending up where it shouldn't be.
Date: Sun, 18 Sep 2016 22:57:38 +0200
To: "Sam S. (via RT)" <perl6-bugs-followup [...] perl.org>
Subject: Re: [perl #129299] [REGEX] Quantified capture group breaks `$/.list`
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Ah, found it: The List iterator assumes that a List cannot have “holes” in it. Apparently it can :-( Going to sleep on how to fix this. Show quoted text
> On 18 Sep 2016, at 19:30, Sam S. (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Sam S. > # Please include the string: [perl #129299] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=129299 > > > > When a quantified capture group matched zero times but the overall regex matches, then the List returned from `$/.list` stops iterating before the corresponding element: > > "ac" ~~ / (a) (b)? (c) /; > say ($0, $1, $2); # (「a」 Nil 「c」) > say $/.list; # (「a」) > say $/.list.map({1}); # (1) > say $/.list.elems; # 3 > say $/.list[0, 1, 2, 3]; # (「a」 (Mu) 「c」 Nil > > Expected behavior would be for `$/.list;` to return `(「a」 Nil 「c」)`. > > mst++ suggested that maybe an InterationEnd is ending up where it shouldn't be.
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Subject: Re: [perl #129299] [REGEX] Quantified capture group breaks `$/.list`
To: "Sam S. (via RT)" <perl6-bugs-followup [...] perl.org>
Date: Sun, 18 Sep 2016 23:28:30 +0200
Download (untitled) / with headers
text/plain 987b
Fixed (for now at least) with 9b6f2eb5434e71f07bc649 . Tests still needed. Show quoted text
> On 18 Sep 2016, at 19:30, Sam S. (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Sam S. > # Please include the string: [perl #129299] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=129299 > > > > When a quantified capture group matched zero times but the overall regex matches, then the List returned from `$/.list` stops iterating before the corresponding element: > > "ac" ~~ / (a) (b)? (c) /; > say ($0, $1, $2); # (「a」 Nil 「c」) > say $/.list; # (「a」) > say $/.list.map({1}); # (1) > say $/.list.elems; # 3 > say $/.list[0, 1, 2, 3]; # (「a」 (Mu) 「c」 Nil > > Expected behavior would be for `$/.list;` to return `(「a」 Nil 「c」)`. > > mst++ suggested that maybe an InterationEnd is ending up where it shouldn't be.
Download (untitled) / with headers
text/plain 556b
Should it really return `(「a」 (Mu) 「c」)` and not `(「a」 Nil 「c」)`, seeing as $1 is also Nil? liz made it work on the List.iterator end by allowing it to iterate over holes in the list, but maybe Match.list should not produce a list with holes at all, but rather a list with Nil in place of missing captures? (Maybe that's what the "for now at least" refers to.) If so, then the `is $two.^name, 'Mu'` test added by zoffix is LTA. Maybe it should just test `nok $two.defined` for now, until it is cleared up what type exactly it should be...
Should we reopen this then?


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org