Browse Source

Allow `swizzle` to take more arguments than the original array length

gingerBill 1 year ago
parent
commit
fd06be2243
2 changed files with 2 additions and 2 deletions
  1. 1 1
      src/check_builtin.cpp
  2. 1 1
      src/llvm_backend_expr.cpp

+ 1 - 1
src/check_builtin.cpp

@@ -2460,7 +2460,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
 			arg_count++;
 		}
 
-		if (arg_count > max_count) {
+		if (false && arg_count > max_count) {
 			error(call, "Too many 'swizzle' indices, %td > %td", arg_count, max_count);
 			return false;
 		} else if (arg_count < 2) {

+ 1 - 1
src/llvm_backend_expr.cpp

@@ -3814,7 +3814,7 @@ gb_internal lbAddr lb_build_array_swizzle_addr(lbProcedure *p, AstCallExpr *ce,
 	Type *type = base_type(lb_addr_type(addr));
 	GB_ASSERT(type->kind == Type_Array);
 	i64 count = type->Array.count;
-	if (count <= 4) {
+	if (count <= 4 && index_count <= 4) {
 		u8 indices[4] = {};
 		u8 index_count = 0;
 		for (i32 i = 1; i < ce->args.count; i++) {