Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add some checks for dumbo's trying to unshift/push infinite lists
  • Loading branch information
lizmat committed Jul 3, 2013
1 parent 2208156 commit 25e2f6b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/List.pm
Expand Up @@ -180,6 +180,7 @@ my class List does Positional {

multi method push(List:D: *@values) {
fail 'Cannot .push to an infinite list' if self.infinite; #MMD?
fail 'Cannot .push an infinite list' if @values.infinite;
my $pos = self.elems;
self.STORE_AT_POS($pos++, @values.shift) while @values.gimme(1);
self;
Expand Down Expand Up @@ -232,6 +233,7 @@ my class List does Positional {
}

multi method unshift(List:D: *@elems) {
fail 'Cannot .unshift an infinite list' if @elems.infinite;
nqp::p6listitems(self);
while @elems {
nqp::unshift($!items, @elems.pop)
Expand Down

0 comments on commit 25e2f6b

Please sign in to comment.