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
hyper-op misbehaves when a Range is on the non-magical side of the op #4272
Comments
From @UtilI tried to translated Perl 5: The cross-op version works. Removing the interactions of Z=> and Whatever, lead to this simplified bug: < Util> m: say [ 10 <<**<< (1,2,3,4) ].perl; Note that the problem persists when `**` is changed to `*`. <Util> m: say [ 10 <<*<< (1,2,3,4) ].perl; Finally, I do not see the problem when the "magic" pointy-side of the hyper is a range; -- |
From @usev6One thing to note is that infix:<**> (and also the hypered version of it) has a tighter precedence than the range operator. Therefore we need parenthesis to get the expected result. (Using a range there works now). $ perl6-m -e 'say 1 <<**<< (1 .. 4)' $ perl6 -e 'say 10 <<**<< 1 .. 4' $ perl6 -e 'say (10 <<**<< 1) .. 4' The thighter precedence was also behind the "incorrect" output of the compound example: $ perl6 -e 'my $base = 10; my %bases = <K M G T> Z=> ( $base <<**<< 1..* ); say %bases' ... which is the same as $ perl6 -e 'my $base = 10; my %bases = <K M G T> Z=> ( ($base <<**<< 1) .. * ); say %bases' Using parenthesis around the infinite range fails with X::HyperOp::Infinite: $ perl6 -e 'my $base = 10; my %bases = <K M G T> Z=> ( $base <<**<< (1 .. *) ); say %bases' But using a finite range works: $ perl6 -e 'my $base = 10; my %bases = <K M G T> Z=> ( $base <<**<< (1 .. 4) ); say %bases' I added three tests to S03-metaops/hyper.t with commit Raku/roast@0e4520aff9. I'm closing this ticket as 'resolved'. |
1 similar comment
From @usev6One thing to note is that infix:<**> (and also the hypered version of it) has a tighter precedence than the range operator. Therefore we need parenthesis to get the expected result. (Using a range there works now). $ perl6-m -e 'say 1 <<**<< (1 .. 4)' $ perl6 -e 'say 10 <<**<< 1 .. 4' $ perl6 -e 'say (10 <<**<< 1) .. 4' The thighter precedence was also behind the "incorrect" output of the compound example: $ perl6 -e 'my $base = 10; my %bases = <K M G T> Z=> ( $base <<**<< 1..* ); say %bases' ... which is the same as $ perl6 -e 'my $base = 10; my %bases = <K M G T> Z=> ( ($base <<**<< 1) .. * ); say %bases' Using parenthesis around the infinite range fails with X::HyperOp::Infinite: $ perl6 -e 'my $base = 10; my %bases = <K M G T> Z=> ( $base <<**<< (1 .. *) ); say %bases' But using a finite range works: $ perl6 -e 'my $base = 10; my %bases = <K M G T> Z=> ( $base <<**<< (1 .. 4) ); say %bases' I added three tests to S03-metaops/hyper.t with commit Raku/roast@0e4520aff9. I'm closing this ticket as 'resolved'. |
@usev6 - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#125265 (status was 'resolved')
Searchable as RT125265$
The text was updated successfully, but these errors were encountered: