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

Anchors ^, ^^, $, $$, «, » confused in <?after> #6468

Closed
p6rt opened this issue Aug 26, 2017 · 10 comments
Closed

Anchors ^, ^^, $, $$, «, » confused in <?after> #6468

p6rt opened this issue Aug 26, 2017 · 10 comments
Labels
regex Regular expressions, pattern matching, user-defined grammars, tokens and rules

Comments

@p6rt
Copy link

p6rt commented Aug 26, 2017

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

Searchable as RT131964$

@p6rt
Copy link
Author

p6rt commented Dec 27, 2015

From xiaowei.lxw@alibaba-inc.com

$ perl6 -e 'say "foo".subst(/<?after ^>/, "^").subst(/<?after $>/, "\$")'$foo^ # should be ^foo$

@p6rt
Copy link
Author

p6rt commented Aug 26, 2017

From @moritz

This is Rakudo version 2017.08-11-g6cec6b7 built on MoarVM version
2017.08.1-19-g151a256
implementing Perl 6.c.

Rakudo confuses <?after ^> with <?after $> in a regex, and the same with
^^ and $$.

The following four test cases should all pass (barring a thinko on my
part), but instead they all fail​:

#!/usr/bin/env perl6
use Test;

given "abc\ndef" {
  is S/ <?after ^> /X/, "Xabc\ndef", '^ in <?after>';
  is S/ <?after $&gt; /X/, "abc\ndefX", '$ in <?after>';
  is S​:g/ <?after ^^> /X/, "Xabc\nXdef", '^^ in <?after>';
  is S​:g/ <?after $$> /X/, "abcX\ndefX", '^^ in <?after>';
}
done-testing

Kudos go to _cronus on #perl6 for asking about a weird behavior, which
led to the discovery of this bug.

Cheers,
Moritz

Moritz Lenz
Design & Architecture (CDA)
noris network
Thomas-Mann-Stra�e 16-20
90471 Nürnberg
Deutschland
Tel +49 911 9352 1517
Fax +49 911 9352 100

moritz.lenz@​noris.de
https://www.noris.de - Mehr Leistung als Standard
Vorstand​: Ingo Kraupa (Vorsitzender), Joachim Astel
Vorsitzender des Aufsichtsrats​: Stefan Schnabel - AG Nürnberg HRB 17689
 
 
 
 

@p6rt
Copy link
Author

p6rt commented Aug 26, 2017

From @moritz

Oh, I forgot to add​: it's not specific to S/// or any kind of substitution; the same problem is in normal regex matches; the substitution is just there to illustrate the point a bit better.

@p6rt
Copy link
Author

p6rt commented Aug 26, 2017

From @moritz

Tests added to S05-metasyntax/lookaround.t in this commit​: Raku/roast@1089a7f9b7

@p6rt
Copy link
Author

p6rt commented Sep 1, 2017

From @zoffixznet

IRC​: https://irclog.perlgeek.de/perl6/2017-09-01#i_15101726

If `^` or `«` is used in `<after>` the match fails​:

15​:13 ab6tract m​: say "What​::Root​::Thing" ~~ /<?after ^ "What​::Root​::"> .*/; say "What​::Root​::Thing" ~~ /<?after "What​::Root​::"> .*/
15​:13 camelia rakudo-moar 909688​: OUTPUT​: «Nil??Thing??»

15​:23 m​: say ".zXXXYzYYY" ~~ /<?after « z> .../
15​:23 camelia rakudo-moar 909688​: OUTPUT​: «Nil?»

Even though, `<|w>` and `<!|w>` in `<after>` as well as `$` in `<before>` do work​:

15​:23 m​: say ".zXXXYzYYY" ~~ /<?after <|w> z> .../
15​:23 camelia rakudo-moar 909688​: OUTPUT​: «?XXX??»
15​:23 Zoffix m​: say ".zXXXYzYYY" ~~ /<?after <!|w> z> .../
15​:23 camelia rakudo-moar 909688​: OUTPUT​: «?YYY??»

15​:17 m​: say "XXXzYYYz" ~~ /... <before z> /
15​:17 camelia rakudo-moar 909688​: OUTPUT​: «?XXX?? before => ???»
15​:17 Zoffix m​: say "XXXzYYYz" ~~ /... <before z$> /
15​:17 camelia rakudo-moar 909688​: OUTPUT​: «?YYY?? before => ???»

@p6rt
Copy link
Author

p6rt commented Sep 5, 2017

@p6rt
Copy link
Author

p6rt commented Sep 5, 2017

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

@p6rt
Copy link
Author

p6rt commented May 8, 2018

From @usev6

This has been fixed with Raku/nqp@075ff765f5

The tests in S05-metasyntax/lookaround.t are passing, so I'm closing this ticket was 'resolved'.

1 similar comment
@p6rt
Copy link
Author

p6rt commented May 8, 2018

From @usev6

This has been fixed with Raku/nqp@075ff765f5

The tests in S05-metasyntax/lookaround.t are passing, so I'm closing this ticket was 'resolved'.

@p6rt
Copy link
Author

p6rt commented May 8, 2018

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

@p6rt p6rt closed this as completed May 8, 2018
@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