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

Smartmatching against a regex in a variable doesn't capture things into $/ in Rakudo #4893

Closed
p6rt opened this issue Dec 20, 2015 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 20, 2015

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

Searchable as RT126969$

@p6rt
Copy link
Author

p6rt commented Dec 20, 2015

From @masak

<masak> m​: say so "foo" ~~ /f(oo)/; say ~$0
<camelia> rakudo-moar 091ee7​: OUTPUT«True␤oo␤»
<masak> m​: constant $R = /f(oo)/; say so "foo" ~~ $R; say ~$0
<camelia> rakudo-moar 091ee7​: OUTPUT«True␤Use of Nil in string context [...]
<masak> the last line not working is a regression (that I just
discovered in a test in a branch in 007)
<masak> is that intentional? feels to me that oughta work just fine.
<lucasb> m​: my \rx = /f(oo)/; say so "foo" ~~ rx; say ~$0
<camelia> rakudo-moar 091ee7​: OUTPUT«True␤Use of Nil in string context [...]
<lucasb> star​: my \rx = /f(oo)/; say so "foo" ~~ rx; say ~$0
<camelia> star-m 2015.09​: OUTPUT«True␤oo␤»
<lucasb> (just showing...)
<masak> well, with this one I kinda half-expect jnthn to pop up
(tomorrow) and say "that's a feature!" or "masak, you submitted an RT
thing that said it should be like that!" :P
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Mar 9, 2016

From @skids

rudi_s++ on IRC noted that in some cases (in a perl -e oneliner or on a single REPL line)
it works as expected, but spread out over multiple REPL lines it does not.

Also raised the question as to whether or not an explicit call to $regex.ACCEPTS should alter $/.

http://irclog.perlgeek.de/perl6/2016-03-09#i_12156052

@p6rt
Copy link
Author

p6rt commented Mar 9, 2016

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

@p6rt
Copy link
Author

p6rt commented Nov 30, 2016

From @briandfoy

This is still broken, and it's important to me.

my $target = 'abcdef';

my $n = 'abc';
my $r = rx/ ( 'abc' ) /;
say "\$r is ", $r.WHAT;
$r.say;

# This returns a Bool
my $result = $target ~~ $r;
say "result is ", $result.WHAT;

# This returns a Match
my $result = $target ~~ rx/ ( 'abc' ) /;
say "result is ", $result.WHAT;

put '$r​: ',
  $target ~~ $r
  ?? "Matched $0" !! 'Misssed';

put 'rx// directly​: ',
  $target ~~ rx/ ( <$n> ) /
  ?? "Matched $0" !! 'Misssed';

put 'm//​: ',
  $target ~~ m/ ( <$n> ) /
  ?? "Matched $0" !! 'Misssed';

@p6rt
Copy link
Author

p6rt commented Dec 4, 2016

From @zoffixznet

On Tue, 29 Nov 2016 22​:24​:43 -0800, comdog wrote​:

This is still broken, and it's important to me.

my $target = 'abcdef';

my $n = 'abc';
my $r = rx/ ( 'abc' ) /;
say "\$r is ", $r.WHAT;
$r.say;

# This returns a Bool
my $result = $target ~~ $r;
say "result is ", $result.WHAT;

# This returns a Match
my $result = $target ~~ rx/ ( 'abc' ) /;
say "result is ", $result.WHAT;

put '$r​: ',
$target ~~ $r
?? "Matched $0" !! 'Misssed';

put 'rx// directly​: ',
$target ~~ rx/ ( <$n> ) /
?? "Matched $0" !! 'Misssed';

put 'm//​: ',
$target ~~ m/ ( <$n> ) /
?? "Matched $0" !! 'Misssed';

This was fixed as part of another dupe ticket in rakudo/rakudo@5ac593e
and tests were added too.

Brian, update to 2016.11 release to receive the fix.

@p6rt
Copy link
Author

p6rt commented Dec 4, 2016

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

@p6rt p6rt closed this as completed Dec 4, 2016
@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