Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate keys in .gist in Match of regex which backtracked in Rakudo #3074

Closed
p6rt opened this issue Apr 4, 2013 · 6 comments
Closed

duplicate keys in .gist in Match of regex which backtracked in Rakudo #3074

p6rt opened this issue Apr 4, 2013 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Apr 4, 2013

Migrated from rt.perl.org#117481 (status was 'resolved')

Searchable as RT117481$

@p6rt
Copy link
Author

p6rt commented Apr 4, 2013

From @masak

<p6eval> rakudo 99e27f​: OUTPUT«「/foo/bar/baz/」␤ dirname =>
「/foo/bar/baz/」␤ dirname => 「/foo/bar/」␤ basename => 「baz」␤␤»
<labster> okay, why do I get two copies of dirname when the match only
succeeds once?
<masak> huuhhnn.
<masak> wut.
<masak> I suspect a backtracking-related glitch.
* masak submits labster's rakudobug
<masak> r​: say ('/foo/bar/baz/' ~~ m/^ $<dirname>=(.* '/'+)?
$<basename>=(<-[\/]>+) '/'* $ /).keys
<p6eval> rakudo 99e27f​: OUTPUT«dirname basename␤»
<masak> labster​: .gist shows double 'dirname' keys, but .keys and .perl don't

The .gist output is bizarre. There should never be duplicate keys in a
Match. I haven't dived into the source code to see how that is even
possible.

@p6rt
Copy link
Author

p6rt commented Apr 4, 2013

From @pmichaud

On Thu, Apr 04, 2013 at 02​:09​:36PM -0700, Carl Mäsak wrote​:

<p6eval> rakudo 99e27f​: OUTPUT«「/foo/bar/baz/」␤ dirname =>
「/foo/bar/baz/」␤ dirname => 「/foo/bar/」␤ basename => 「baz」␤␤»
<labster> okay, why do I get two copies of dirname when the match only
succeeds once?
<masak> huuhhnn.
<masak> wut.
<masak> I suspect a backtracking-related glitch.
...
The .gist output is bizarre. There should never be duplicate keys in a
Match.

The "gist" method uses ".caps" for the match output, so I suspect
the culprit is in "caps", or in Match.gist's incorrect usage of .caps .

Duplicate keys can appear in the .caps stream.

Pm

@p6rt
Copy link
Author

p6rt commented Apr 4, 2013

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 10, 2014

From @usev6

There is no longer a duplicate key in the .gist output​:

$ perl6-m -e "say ('/foo/bar/baz/' ~~ m/^ $&lt;dirname&gt;=(.* '/'+)? $&lt;basename>=(<-[\/]>+) '/'* $ /).gist"
「/foo/bar/baz/」
dirname => 「/foo/bar/」
basename => 「baz」

I added a test to S02-names-vars/list_array_perl.t (couldn't find a better place) with the following commit​: Raku/roast@9acc51a8d9

Please note​: All of the above is under the assumption that the originial command (which is missing from the IRC log) was​:

r​: say ('/foo/bar/baz/' ~~ m/^ $&lt;dirname&gt;=(.* '/'+)? $&lt;basename>=(<-[\/]>+) '/'* $ /).gist

If I misinterpreted the problem, please reopen the ticket.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 10, 2014

From @usev6

There is no longer a duplicate key in the .gist output​:

$ perl6-m -e "say ('/foo/bar/baz/' ~~ m/^ $&lt;dirname&gt;=(.* '/'+)? $&lt;basename>=(<-[\/]>+) '/'* $ /).gist"
「/foo/bar/baz/」
dirname => 「/foo/bar/」
basename => 「baz」

I added a test to S02-names-vars/list_array_perl.t (couldn't find a better place) with the following commit​: Raku/roast@9acc51a8d9

Please note​: All of the above is under the assumption that the originial command (which is missing from the IRC log) was​:

r​: say ('/foo/bar/baz/' ~~ m/^ $&lt;dirname&gt;=(.* '/'+)? $&lt;basename>=(<-[\/]>+) '/'* $ /).gist

If I misinterpreted the problem, please reopen the ticket.

@p6rt
Copy link
Author

p6rt commented Oct 10, 2014

@usev6 - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant