On Wed, Sep 14, 2016 at 05:10:55PM -0700, Zoffix Znet wrote:
> <Zoffix> m: my $input = '(\d\d\d)'; my $m = 'a 123' ~~ /<$input>/; dd 
> [$m.list];
> <camelia> rakudo-moar 2c95f7: OUTPUT«[]␤»
> 
> 
> Expected results: output is the same, as the $input contains a capture that 
> should capture stuff when interpolated.

<$input> is non-capturing, so even though it contains a $0 capture, its result
won't be held by the outermost Match object.

Rewrite to <input=$input> or $0=<$input> and you'll see the resulting capture.

   <pmichaud> m: my $input = '(\d\d\d)';  my $m = 'a 123' ~~ /<input=$input>/; 
say $m
   <camelia> rakudo-moar 2c95f7: OUTPUT«「123」␤ input => 「123」␤  0 => 「123」␤»
   <pmichaud> m: my $input = '(\d\d\d)';  my $m = 'a 123' ~~ /$0=<$input>/; say 
$m
   <camelia> rakudo-moar 2c95f7: OUTPUT«「123」␤ 0 => 「123」␤  0 => 「123」␤»

As far as I know, there's not a way to have a "top-level" capturing 
interpolation except by using some form of the <foo=...> or $0=<...>  
syntax.  It's always consider a sub-rule capture.

Rejecting ticket as not-a-bug.

Pm

Reply via email to