diff --git a/src/core/Array.pm b/src/core/Array.pm index fa776cfc849..22b8019801a 100644 --- a/src/core/Array.pm +++ b/src/core/Array.pm @@ -201,7 +201,13 @@ my class Array { # declared in BOOTSTRAP proto method new(|) { * } multi method new(:$shape!) { nqp::if( - nqp::defined($shape),set-shape(self,$shape),nqp::create(self) + nqp::defined($shape), + set-shape(self,$shape), + nqp::if( + Metamodel::EnumHOW.ACCEPTS($shape.HOW), + set-shape(self,$shape.^elems), + nqp::create(self) + ) ) } multi method new() { @@ -209,7 +215,13 @@ my class Array { # declared in BOOTSTRAP } multi method new(\values, :$shape!) { nqp::if( - nqp::defined($shape),set-shape(self,$shape),nqp::create(self) + nqp::defined($shape), + set-shape(self,$shape), + nqp::if( + Metamodel::EnumHOW.ACCEPTS($shape.HOW), + set-shape(self,$shape.^elems), + nqp::create(self) + ) ).STORE(values) } multi method new(\values) { @@ -217,7 +229,13 @@ my class Array { # declared in BOOTSTRAP } multi method new(**@values is raw, :$shape!) { nqp::if( - nqp::defined($shape),set-shape(self,$shape),nqp::create(self) + nqp::defined($shape), + set-shape(self,$shape), + nqp::if( + Metamodel::EnumHOW.ACCEPTS($shape.HOW), + set-shape(self,$shape.^elems), + nqp::create(self) + ) ).STORE(@values) } multi method new(**@values is raw) { diff --git a/src/core/ShapedNArray.pm b/src/core/ShapedNArray.pm index 66ed9b3398f..16f5731c235 100644 --- a/src/core/ShapedNArray.pm +++ b/src/core/ShapedNArray.pm @@ -6,13 +6,9 @@ sub set-shape(\base, \shape) is raw { nqp::stmts( (my $shape := nqp::decont(nqp::if( - Metamodel::EnumHOW.ACCEPTS(shape.HOW), - shape.^elems, - nqp::if( - nqp::istype(shape,List), - shape, - shape.list - ) + nqp::istype(shape,List), + shape, + shape.list ))), nqp::if( (my int $dimensions = $shape.elems), # reifies diff --git a/src/core/TypedArray.pm b/src/core/TypedArray.pm index a97ce0bef24..9922bb5903e 100644 --- a/src/core/TypedArray.pm +++ b/src/core/TypedArray.pm @@ -5,7 +5,13 @@ proto method new(|) { * } multi method new(:$shape!) { set-descriptor(nqp::if( - nqp::defined($shape),set-shape(self,$shape),nqp::create(self) + nqp::defined($shape), + set-shape(self,$shape), + nqp::if( + Metamodel::EnumHOW.ACCEPTS($shape.HOW), + set-shape(self,$shape.^elems), + nqp::create(self) + ) )) } multi method new() { @@ -13,7 +19,13 @@ } multi method new(\values, :$shape!) { set-descriptor(nqp::if( - nqp::defined($shape),set-shape(self,$shape),nqp::create(self) + nqp::defined($shape), + set-shape(self,$shape), + nqp::if( + Metamodel::EnumHOW.ACCEPTS($shape.HOW), + set-shape(self,$shape.^elems), + nqp::create(self) + ) )).STORE(values) } multi method new(\values) { @@ -21,7 +33,13 @@ } multi method new(**@values is raw, :$shape!) { set-descriptor(nqp::if( - nqp::defined($shape),set-shape(self,$shape),nqp::create(self) + nqp::defined($shape), + set-shape(self,$shape), + nqp::if( + Metamodel::EnumHOW.ACCEPTS($shape.HOW), + set-shape(self,$shape.^elems), + nqp::create(self) + ) )).STORE(@values) } multi method new(**@values is raw) {