@@ -7,6 +7,7 @@ use std::{
77
88use ecow:: eco_vec;
99
10+ use crate :: algorithm:: validate_size;
1011use crate :: fill:: FillValue ;
1112use crate :: { algorithm:: loops:: flip, array:: * , Uiua , UiuaError , UiuaResult , Value } ;
1213use crate :: { Complex , Shape } ;
@@ -145,7 +146,8 @@ where
145146
146147 // dbg!(&a.shape, &b.shape, &new_shape);
147148
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] ;
149151 if !new_shape. contains ( & 0 ) {
150152 let slice = new_data. make_mut ( ) ;
151153 let a_fill = a_fill. as_ref ( ) . ok ( ) ;
@@ -375,6 +377,7 @@ where
375377 } ;
376378 let ( new_shape, requires_fill) =
377379 derive_new_shape ( & a. shape , & b. shape , fill. as_ref ( ) . err ( ) . copied ( ) , env) ?;
380+ validate_size :: < T > ( new_shape. iter ( ) . copied ( ) , env) ?;
378381 let fill = if requires_fill { fill. ok ( ) } else { None } ;
379382
380383 // dbg!(a.shape, b.shape, &new_shape, &fill);
0 commit comments