Skip to content

Commit

Permalink
Make sure we mention correct push/append if lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Oct 1, 2015
1 parent 692aaec commit a10ec97
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/Array.pm
Expand Up @@ -496,9 +496,10 @@ my class Array { # declared in BOOTSTRAP
$value;
}

# MUST have a separate Slip variant
# MUST have a separate Slip variant to have it slip
multi method push(Array:D: Slip \value) {
self!ensure-allocated();
fail X::Cannot::Lazy.new(action => 'push to') if self.is-lazy;
self!append-list(value);
}
multi method push(Array:D: \value) {
Expand All @@ -513,14 +514,14 @@ my class Array { # declared in BOOTSTRAP
}
multi method push(Array:D: **@values is raw) {
self!ensure-allocated();
fail X::Cannot::Lazy.new(action => 'push to') if self.is-lazy;
self!append-list(@values)
}

multi method append(Array:D: \value) {
self!ensure-allocated();
fail X::Cannot::Lazy.new(action => 'append to') if self.is-lazy;
if nqp::iscont(value) || nqp::not_i(nqp::istype(value, Iterable)) {
fail X::Cannot::Lazy.new(action => 'push to') if self.is-lazy;

nqp::push(
nqp::getattr(self, List, '$!reified'),
nqp::assign(nqp::p6scalarfromdesc($!descriptor), value)
Expand All @@ -533,11 +534,10 @@ my class Array { # declared in BOOTSTRAP
}
multi method append(Array:D: **@values is raw) {
self!ensure-allocated();
fail X::Cannot::Lazy.new(action => 'append to') if self.is-lazy;
self!append-list(@values)
}
method !append-list(@values) {
fail X::Cannot::Lazy.new(action => 'push to') if self.is-lazy;

my \values-iter = @values.iterator;
my \reified := nqp::getattr(self, List, '$!reified');
my \target := ArrayReificationTarget.new(reified,
Expand Down

0 comments on commit a10ec97

Please sign in to comment.