@@ -7,6 +7,7 @@ use std::{
7
7
8
8
use ecow:: eco_vec;
9
9
10
+ use crate :: algorithm:: validate_size;
10
11
use crate :: fill:: FillValue ;
11
12
use crate :: { algorithm:: loops:: flip, array:: * , Uiua , UiuaError , UiuaResult , Value } ;
12
13
use crate :: { Complex , Shape } ;
@@ -145,7 +146,8 @@ where
145
146
146
147
// dbg!(&a.shape, &b.shape, &new_shape);
147
148
148
- let mut new_data = eco_vec ! [ C :: default ( ) ; new_shape. elements( ) ] ;
149
+ let elem_count = validate_size :: < C > ( new_shape. iter ( ) . copied ( ) , env) ?;
150
+ let mut new_data = eco_vec ! [ C :: default ( ) ; elem_count] ;
149
151
if !new_shape. contains ( & 0 ) {
150
152
let slice = new_data. make_mut ( ) ;
151
153
let a_fill = a_fill. as_ref ( ) . ok ( ) ;
@@ -375,6 +377,7 @@ where
375
377
} ;
376
378
let ( new_shape, requires_fill) =
377
379
derive_new_shape ( & a. shape , & b. shape , fill. as_ref ( ) . err ( ) . copied ( ) , env) ?;
380
+ validate_size :: < T > ( new_shape. iter ( ) . copied ( ) , env) ?;
378
381
let fill = if requires_fill { fill. ok ( ) } else { None } ;
379
382
380
383
// dbg!(a.shape, b.shape, &new_shape, &fill);
0 commit comments