sanity check parameters List.rotor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/core/List.pm b/src/core/List.pm | |
| index 17bf04b..5d3cc5f 100644 | |
| --- a/src/core/List.pm | |
| +++ b/src/core/List.pm | |
| @@ -563,15 +563,23 @@ my class List does Positional { # declared in BOOTSTRAP | |
| } | |
| method rotor(*@cycle, :$partial) { | |
| - my $finished = 0; | |
| + | |
| + die "Must specify at least one pattern of cyclism" unless @cycle; | |
| + | |
| # (Note, the xx should be harmless if the cycle is already infinite by accident.) | |
| my @c := @cycle.infinite ?? @cycle !! @cycle xx *; | |
| + my $finished = 0; | |
| gather for @c -> $s { | |
| my $elems; | |
| my $gap; | |
| if $s ~~ Pair { $elems = +$s.key; $gap = +$s.value; } | |
| else { $elems = +$s; $gap = 0; } | |
| + fail X::OutOfRange.new(:what<Elements>,:got($elems),:range<1..Inf>) | |
| + if $elems < 1; | |
| + fail X::OutOfRange.new(:what<Start>,:got($finished),:range(0..Inf)) | |
| + if $finished < 0; | |
| + | |
| if $finished + $elems <= self.gimme($finished + $elems) { | |
| take self[$finished ..^ $finished + $elems]; | |
| $finished += $elems + $gap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ 6 '{ (^10).rotor(-1 => 1) }' | pbcopy | |
| Unhandled exception: Could not find symbol '&Return' | |
| at src/gen/m-CORE.setting:14576 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:throw:121) | |
| from src/gen/m-CORE.setting:16449 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:<anon>:33) | |
| from src/gen/m-Metamodel.nqp:2914 (blib/Perl6/Metamodel.moarvm:find_method_fallback:69) | |
| from src/gen/m-Metamodel.nqp:1053 (blib/Perl6/Metamodel.moarvm:find_method:110) | |
| from src/gen/m-BOOTSTRAP.nqp:2732 (blib/Perl6/BOOTSTRAP.moarvm::85) | |
| from src/gen/m-CORE.setting:889 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:EXHAUST:32) | |
| from src/gen/m-CORE.setting:16462 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:fail:36) | |
| from src/gen/m-CORE.setting:16458 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:fail:25) | |
| from src/gen/m-CORE.setting:10813 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm::133) | |
| from src/gen/m-CORE.setting:10036 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm::558) | |
| from src/gen/m-CORE.setting:9959 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:reify:58) | |
| from src/gen/m-CORE.setting:9875 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm::95) | |
| from src/gen/m-CORE.setting:9846 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm::0) | |
| from src/gen/m-CORE.setting:9846 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:reify:58) | |
| from src/gen/m-CORE.setting:10372 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:gimme:4294967295) | |
| from src/gen/m-CORE.setting:10914 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:sink:4294967295) | |
| from src/gen/m-CORE.setting:10807 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm::31) | |
| from src/gen/m-CORE.setting:10179 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm::18) | |
| from src/gen/m-CORE.setting:10183 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm::10) | |
| from src/gen/m-CORE.setting:10210 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm::48) | |
| from src/gen/m-CORE.setting:10203 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:reify:52) | |
| from src/gen/m-CORE.setting:9875 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm::95) | |
| from src/gen/m-CORE.setting:9846 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm::0) | |
| from src/gen/m-CORE.setting:9846 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:reify:58) | |
| from src/gen/m-CORE.setting:10372 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:gimme:4294967295) | |
| from src/gen/m-CORE.setting:10914 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/./CORE.setting.moarvm:sink:4294967295) | |
| from src/gen/m-main.nqp:41 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/perl6.moarvm:MAIN:40) | |
| from src/gen/m-main.nqp:35 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/perl6.moarvm:<mainline>:197) | |
| from <unknown>:1 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/perl6.moarvm:<main>:8) | |
| from <unknown>:1 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/perl6.moarvm:<entry>:9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment