File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Top Open diff view settings Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Top Open diff view settings Original file line number Diff line number Diff line change @@ -5471,8 +5471,22 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {
54715471 case TypeTableEntryIdPointer:
54725472 case TypeTableEntryIdFn:
54735473 return const_values_equal_ptr (a, b);
5474- case TypeTableEntryIdArray:
5475- zig_panic (" TODO" );
5474+ case TypeTableEntryIdArray: {
5475+ assert (a->type ->data .array .len == b->type ->data .array .len );
5476+ assert (a->data .x_array .special != ConstArraySpecialUndef);
5477+ assert (b->data .x_array .special != ConstArraySpecialUndef);
5478+
5479+ size_t len = a->type ->data .array .len ;
5480+ ConstExprValue *a_elems = a->data .x_array .s_none .elements ;
5481+ ConstExprValue *b_elems = b->data .x_array .s_none .elements ;
5482+
5483+ for (size_t i = 0 ; i < len; ++i) {
5484+ if (!const_values_equal (&a_elems[i], &b_elems[i]))
5485+ return false ;
5486+ }
5487+
5488+ return true ;
5489+ }
54765490 case TypeTableEntryIdStruct:
54775491 for (size_t i = 0 ; i < a->type ->data .structure .src_field_count ; i += 1 ) {
54785492 ConstExprValue *field_a = &a->data .x_struct .fields [i];
Original file line number Diff line number Diff line change @@ -152,3 +152,11 @@ fn testImplicitCastSingleItemPtr() void {
152152 slice [0 ] += 1 ;
153153 assert (byte == 101 );
154154}
155+
156+ fn testArrayByValAtComptime (b : [2 ]u8 ) u8 { return b [0 ]; }
157+
158+ test "comptime evalutating function that takes array by value" {
159+ const arr = []u8 {0 ,1 };
160+ _ = comptime testArrayByValAtComptime (arr );
161+ _ = comptime testArrayByValAtComptime (arr );
162+ }
You can’t perform that action at this time.
0 commit comments