Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
RT #125123: Improve error message when pushing/unshifting to an int-t…
…yped array
  • Loading branch information
moritz committed Nov 14, 2015
1 parent f5fbcde commit 94ad45b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/core/native_array.pm
Expand Up @@ -79,6 +79,13 @@ class array does Iterable is repr('VMArray') {
nqp::push_i(self, $value);
self
}
multi method push(array:D: Mu \value) {
X::TypeCheck.new(
operation => 'push to array',
got => value,
expected => T,
).throw;
}
multi method append(array:D: @values) {
fail X::Cannot::Lazy.new(:action<push>, :what(self.^name))
if @values.is-lazy;
Expand Down Expand Up @@ -106,6 +113,13 @@ class array does Iterable is repr('VMArray') {
nqp::unshift_i(self, $value);
self
}
multi method unshift(array:D: Mu \value) {
X::TypeCheck.new(
operation => 'push to array',
got => value,
expected => T,
).throw;
}
multi method unshift(array:D: @values) {
fail X::Cannot::Lazy.new(:action<unshift>, :what(self.^name))
if @values.is-lazy;
Expand Down

0 comments on commit 94ad45b

Please sign in to comment.