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

Rematching in a code assertion inside a regex doesn't recognize Match variable shorthands #4894

Open
p6rt opened this issue Dec 20, 2015 · 1 comment
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 20, 2015

Migrated from rt.perl.org#126971 (status was 'new')

Searchable as RT126971$

@p6rt
Copy link
Author

p6rt commented Dec 20, 2015

From @peschwa

02​:03 < lucs> m​: say so("a" ~~ / (.) <?{ $0 ~~ /'a'/ && say("\$0 is now ", $0.WHAT) }> /)
02​:03 <+camelia> rakudo-moar 091ee7​: OUTPUT«$0 is now Nil␤True␤»
[...]
02​:05 < lucs> TimToady​: So would that ^^ be a bug or a don't-do-that?
[...]
02​:06 < psch> m​: say so("a" ~~ / (.) <?{ $0 ~~ /'a'/ && say("\$/ is now ", $0.WHAT) }> /)
[...]
02​:06 <+camelia> rakudo-moar 091ee7​: OUTPUT«$/ is now Nil␤True␤»
02​:06 < psch> huh
02​:06 < psch> that seems wrong to me, at least
02​:06 < psch> well, no
02​:07 < psch> accessing $/ there is a "works sometimes" workaround for accessing the CURSOR special name
[...]
02​:07 < psch> m​: say so("a" ~~ / (.) <?{ $0 ~~ /'a'/ &amp;&amp; say("\$¢ is now ", $¢.WHAT) }> /)
02​:07 <+camelia> rakudo-moar 091ee7​: OUTPUT«$¢ is now Nil␤True␤»
[...]
02​:08 < psch> m​: say so("a" ~~ / (.) <?{ $0 ~~ /'a'/ &amp;&amp; say("\$/ is now ", $/.WHAT) }> /)
02​:08 <+camelia> rakudo-moar 091ee7​: OUTPUT«$/ is now (Match)␤True␤»
[...]
02​:08 < psch> m​: say so("a" ~~ / (.) <?{ $0 ~~ /'a'/ &amp;&amp; say("\$/[0] is now ", $/[0].WHAT) }> /)
02​:08 <+camelia> rakudo-moar 091ee7​: OUTPUT«$/[0] is now Nil␤True␤»
02​:08 < psch> lucs​: the hunch is that the switch from Perl6​::Grammar to NQP​::P6Regex messes something up with accessing the different
  interpretations of $/
02​:09 < psch> as in, the code block inside the regex doesn't build the same lookup for $0 as it would outside of a regex
[...]
02​:09 < psch> that might easily be wrong though, but the fact that $/ is Match seems to hint at it...
[...]
02​:11 < psch> 'cause even if $/ isn't supposed to work there (which ISTR it isn't), at least $¢ should

In case of bad editing refer to http://irclog.perlgeek.de/perl6/2015-12-20#i_11746338 and onward.

The underlying issue seems to be that the special name $/ retains some kind of Match object when referenced inside any kind of code assertion inside of a regex, but accessing positional captures fails. I seem to recall mention of $/ not necessarily being valid in a regex, but trying to access $¢ instead is similarly fruitless.

@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