@@ -18,7 +18,7 @@ const ReduceOp = std.builtin.ReduceOp;
1818/// A compile error is raised if the type passed to this function is not an array
1919/// type of vector compatible elements or is an array with a sentinel value.
2020pub fn Vec (comptime ArrayType : type ) type {
21- const arr_info = @typeInfo (ArrayType ).Array ;
21+ const arr_info = @typeInfo (ArrayType ).array ;
2222 if (arr_info .sentinel != null )
2323 @compileError ("Vectors cannot have sentinel values" );
2424 return @Vector (arr_info .len , arr_info .child );
@@ -241,7 +241,7 @@ pub fn Signed(comptime V: type) type {
241241 const vec_info = @typeInfo (V ).vector ;
242242 return switch (vec_info .child ) {
243243 isize = > V ,
244- usize = > Vec ([vec_info ]isize ),
244+ usize = > Vec ([vec_info . len ]isize ),
245245 else = > switch (@typeInfo (vec_info .child )) {
246246 .int = > | int_info | Vec ([vec_info .len ]std .meta .Int (.signed , int_info .bits )),
247247 else = > unreachable ,
@@ -250,7 +250,7 @@ pub fn Signed(comptime V: type) type {
250250}
251251
252252test Signed {
253- comptime {
253+ comptime {
254254 assert (Signed (Vec ([15 ]u32 )) == Vec ([15 ]i32 ));
255255 assert (Signed (Vec ([27 ]i32 )) == Vec ([27 ]i32 ));
256256 assert (Signed (Vec ([0 ]u1 )) == Vec ([0 ]i1 ));
@@ -273,14 +273,18 @@ pub inline fn signedCast(int_vec: anytype) Signed(From(@TypeOf(int_vec))) {
273273/// elements are unsigned integers the same size element type of `V`
274274pub fn Unsigned (comptime V : type ) type {
275275 const vec_info = @typeInfo (V ).vector ;
276- return switch (@typeInfo (vec_info .child )) {
277- .int = > | int_info | Vec ([vec_info .len ]std .meta .Int (.unsigned , int_info .bits )),
278- else = > unreachable ,
276+ return switch (vec_info .child ) {
277+ usize = > V ,
278+ isize = > Vec ([vec_info .len ]usize ),
279+ else = > switch (@typeInfo (vec_info .child )) {
280+ .int = > | int_info | Vec ([vec_info .len ]std .meta .Int (.unsigned , int_info .bits )),
281+ else = > unreachable ,
282+ },
279283 };
280284}
281285
282286test Unsigned {
283- comptime {
287+ comptime {
284288 assert (Unsigned (Vec ([15 ]u32 )) == Vec ([15 ]u32 ));
285289 assert (Unsigned (Vec ([27 ]i32 )) == Vec ([27 ]u32 ));
286290 assert (Unsigned (Vec ([0 ]i1 )) == Vec ([0 ]u1 ));
0 commit comments