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
Capture with flattened array does not match #2989
Comments
From @bbkrFor sample class on Rakudo 2012.11 class A { method foo (Int) {} }; signature matches without problem when it is declared directly in code say \(A, 1) ~~ A.^find_method("foo").signature; but when signature is created from array it will not match my @t = 1; say \(A, @t) ~~ A.^find_method("foo").signature; Both signatures looks the same say \(A, 1).perl |
From @moritzOn Wed Dec 05 15:00:24 2012, pawel.pabian@implix.com wrote:
s/signature/capture/
s/signatures/captures/
That's a bug in Capture.perl, which flattens out the array @t. But Rakudo is correct to reject binding \(A, @t) to (A, Int), because If you do want to flatten out the @t, write it as \(A, |@t). Cheers, |
The RT System itself - Status changed from 'new' to 'open' |
From @bbkr
That was the first thing I've tried, but it produces syntax error: $ perl6 -e 'my @t; \(|@t)' |
From @bbkrI've also tried \(A, @t.flat) and it still won't match |
From @usev6There were two different problems here: 1) It was not possible to flatten an array within \(...). This has been fixed: $ perl6 -e 'my @t = 1, 2; say \(|@t)' [BTW: It was possible to do 'Capture(|@t)' before, only with the unary backslash operator it didn't work.] The smartmatch from the OP also works with |@t (but it fails as expected without flattening the array). $ perl6 -e 'class A { method foo (Int) {} }; my @t = 1; say \(A, |@t) ~~ A.^find_method("foo").signature;' $ perl6 -e 'class A { method foo (Int) {} }; my @t = 1; say \(A, @t) ~~ A.^find_method("foo").signature;' I added a test to S02-types/capture.t with commit Raku/roast@7c4672ced8 2) Capture.perl flattens elements. This is still an issue, but there is a separate ticket: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=114100. I'll link to that ticket, but since the main issue 1) is solved, I'm going to close this ticket as 'resolved'. |
1 similar comment
From @usev6There were two different problems here: 1) It was not possible to flatten an array within \(...). This has been fixed: $ perl6 -e 'my @t = 1, 2; say \(|@t)' [BTW: It was possible to do 'Capture(|@t)' before, only with the unary backslash operator it didn't work.] The smartmatch from the OP also works with |@t (but it fails as expected without flattening the array). $ perl6 -e 'class A { method foo (Int) {} }; my @t = 1; say \(A, |@t) ~~ A.^find_method("foo").signature;' $ perl6 -e 'class A { method foo (Int) {} }; my @t = 1; say \(A, @t) ~~ A.^find_method("foo").signature;' I added a test to S02-types/capture.t with commit Raku/roast@7c4672ced8 2) Capture.perl flattens elements. This is still an issue, but there is a separate ticket: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=114100. I'll link to that ticket, but since the main issue 1) is solved, I'm going to close this ticket as 'resolved'. |
@usev6 - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#116002 (status was 'resolved')
Searchable as RT116002$
The text was updated successfully, but these errors were encountered: