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

Declarative and procedural conjunctions in regex don't remember the keys of positional captures #3752

Open
p6rt opened this issue Mar 22, 2015 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 22, 2015

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

Searchable as RT124149$

@p6rt
Copy link
Author

p6rt commented Mar 22, 2015

From @peschwa

19​:43 < psch> m​: say ("a" ~~ /(.) | ./); say ("a" ~~ /(.) & ./)
19​:43 <+camelia> rakudo-moar 5778e8​: OUTPUT«「a」␤ 0 => 「a」␤「a」␤ => 「a」␤»
19​:43 < psch> the mysterious case of the disappearing 0
19​:43 < FROGGS> O.o
19​:44 < Mouq> m​: say ("a" ~~ /. & (.)/)
[...]
19​:44 <+camelia> rakudo-moar 5778e8​: OUTPUT«「a」␤ => 「a」␤»
19​:44 < psch> nothing up my sleeve!
19​:44 < FROGGS> m​: say ("a" ~~ /(.) | ./); $/ := Nil; say ("a" ~~ /(.) & ./)
19​:44 <+camelia> rakudo-moar 5778e8​: OUTPUT«「a」␤ 0 => 「a」␤Cannot assign to an immutable value␤ in method ACCEPTS at src/gen/m-CORE.setting​:16293␤ in block <unit> at /tmp/8whqFAKjvR​:1␤␤»
[...]
19​:44 < FROGGS> m​: say ("a" ~~ /(.) | ./); $/ = Nil; say ("a" ~~ /(.) & ./)
19​:44 <+camelia> rakudo-moar 5778e8​: OUTPUT«「a」␤ 0 => 「a」␤「a」␤ => 「a」␤»
[...]
19​:45 < psch> that kind of threw a wrench in my attempt to make .caps more reliable
[...]
19​:45 < jnthn> psch​: At a guess, the code generated for the & stuff could be mis-managing the cstack
19​:45 < jnthn> I forget how on earth & is compiled, but it does involve some trickery with the marks.
[...]
19​:46 < psch> jnthn​: okay. the regex match code isn't for me, though. i'll RT it

19​:54 <psch> m​: say "a" ~~ /(.) && ./
19​:54 <camelia> rakudo-moar 5778e8​: OUTPUT«「a」␤ => 「a」␤»

@p6rt
Copy link
Author

p6rt commented May 21, 2016

From @smls

The behavior is different now on Rakudo 2016.04-210-gc59e4dc.

The procedural version (&&) seems to handle captures correctly now​:

  ➜ say "a" ~~ / . && (.)/; # 「a」␤ 0 => 「a」
  ➜ say "a" ~~ /(.) && . /; # 「a」␤ 0 => 「a」
  ➜ say "a" ~~ /(.) && (.)/; # 「a」␤ 0 => 「a」␤ 1 => 「a」

However, the declarative version (&) does not seem to remember its captures at all​:

  ➜ say "a" ~~ / . & (.)/; # 「a」
  ➜ say "a" ~~ /(.) & . /; # 「a」
  ➜ say "a" ~~ /(.) & (.)/; # 「a」

@p6rt
Copy link
Author

p6rt commented May 21, 2016

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

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant