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

Array interpolation @foo doesn't backtrack #5239

Open
p6rt opened this issue Apr 15, 2016 · 7 comments
Open

Array interpolation @foo doesn't backtrack #5239

p6rt opened this issue Apr 15, 2016 · 7 comments
Labels
regex Regular expressions, pattern matching, user-defined grammars, tokens and rules

Comments

@p6rt
Copy link

p6rt commented Apr 15, 2016

Migrated from rt.perl.org#127906 (status was 'open')

Searchable as RT127906$

@p6rt
Copy link
Author

p6rt commented Apr 15, 2016

From tomentiruran@gmail.com

The attached file displays the bug, and includes explanation and per6 -V output.

Thanks, the language is fun, apart from the bugs!

@p6rt
Copy link
Author

p6rt commented Apr 15, 2016

@p6rt
Copy link
Author

p6rt commented Jul 10, 2016

From @zoffixznet

Still present in 2016.06-154-g55c359e built on MoarVM version 2016.06-9-g8fc21d5

Seems a very specific combination that causes it to fail​:

zoffix@​VirtualBox​:~$ perl6 -e 'my @​stem = <b bc>; "bc" ~~ / "a" || @​stem >> / or say "Failed"'
Failed
zoffix@​VirtualBox​:~$ perl6 -e 'my @​stem = <b bc>; "b" ~~ / "a" || @​stem >> / or say "Failed"'
zoffix@​VirtualBox​:~$ perl6 -e 'my @​stem = <bc b>; "b" ~~ / "a" || @​stem >> / or say "Failed"'
zoffix@​VirtualBox​:~$ perl6 -e 'my @​stem = <bc b>; "bc" ~~ / "a" || @​stem >> / or say "Failed"'
zoffix@​VirtualBox​:~$

@p6rt
Copy link
Author

p6rt commented Jul 20, 2016

From @zoffixznet

I was able to golf it a bit further (still present in Rakudo 58dc8c). Removing >> or changing first-match || to longest-match | no longer shows the bug​:

m​: "bc" ~~ /||@​(<b bc>) >>/ or say "Failed"
rakudo-moar 58dc8c​: OUTPUT«Failed␤»

@p6rt
Copy link
Author

p6rt commented Jul 20, 2016

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

@p6rt
Copy link
Author

p6rt commented Oct 7, 2017

From @smls

On Wed, 20 Jul 2016 08​:32​:12 -0700, cpan@​zoffix.com wrote​:

I was able to golf it a bit further (still present in Rakudo 58dc8c).
Removing >> or changing first-match || to longest-match | no longer
shows the bug​:

m​: "bc" ~~ /||@​(<b bc>) >>/ or say "Failed"
rakudo-moar 58dc8c​: OUTPUT«Failed␤»

Still present in​:

  This is Rakudo version 2017.09-227-g8ff76b596
  built on MoarVM version 2017.09.1-575-gd4e230a6
  implementing Perl 6.c.

And it's not specific to `>>`. Even simpler test-case​:

  ➜ say "abc" ~~ /[ a || ab ] c/; # 「abc」
  ➜ say "abc" ~~ /||@​(<a ab>) c/; # Nil

It looks like it simply refuses to backtrack into `||@​`.

@p6rt
Copy link
Author

p6rt commented Oct 7, 2017

From @smls

It affects `|` array interpolation as well​:

  ➜ say "ab" ~~ / < ab a > b /; # 「ab」
  ➜ say "ab" ~~ / @​(<ab a>) b /; # Nil
  ➜ say "ab" ~~ / |@​(<ab a>) b /; # Nil

@p6rt p6rt added the regex Regular expressions, pattern matching, user-defined grammars, tokens and rules label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regex Regular expressions, pattern matching, user-defined grammars, tokens and rules
Projects
None yet
Development

No branches or pull requests

1 participant