Skip to content

Commit

Permalink
Liberalize "is it shaped" checking.
Browse files Browse the repository at this point in the history
So the code works if the source isn't Array, but is shaped.
  • Loading branch information
jnthn committed Nov 20, 2015
1 parent 6d8ca4c commit 5777a46
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/Array.pm
Expand Up @@ -230,16 +230,17 @@ my class Array { # declared in BOOTSTRAP
proto method STORE(|) { * }
multi method STORE(::?CLASS:D: Iterable:D \in) {
allocate-shaped-storage(self, self.shape);
if nqp::istype(in, ShapedArray) {
if self.shape eqv in.shape {
my \in-shape = nqp::can(in, 'shape') ?? in.shape !! Nil;
if in-shape && !nqp::istype(in-shape.AT-POS(0), Whatever) {
if self.shape eqv in-shape {
# Can do a VM-supported memcpy-like thing in the future
for self.keys {
self.ASSIGN-POS(|$_, in.AT-POS(|$_))
}
}
else {
X::Assignment::ArrayShapeMismatch.new(
source-shape => in.shape,
source-shape => in-shape,
target-shape => self.shape
).throw
}
Expand Down

0 comments on commit 5777a46

Please sign in to comment.