aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 21487c231..c38bec9b7 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -4347,17 +4347,27 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
case BuiltinProc_swizzle: {
// swizzle :: proc(v: [N]T, ..int) -> [M]T
Type *type = base_type(operand->type);
- if (!is_type_array(type)) {
+ i64 max_count = 0;
+ Type *elem_type = nullptr;
+
+ if (!is_type_array(type) && !is_type_simd_vector(type)) {
gbString type_str = type_to_string(operand->type);
error(call,
- "You can only 'swizzle' an array, got '%s'",
+ "'swizzle' is only allowed on an array or #simd vector, got '%s'",
type_str);
gb_string_free(type_str);
return false;
}
-
- i64 max_count = type->Array.count;
- Type *elem_type = type->Array.elem;
+ if (type->kind == Type_Array) {
+ max_count = type->Array.count;
+ elem_type = type->Array.elem;
+ } else if (type->kind == Type_SimdVector) {
+ max_count = type->SimdVector.count;
+ elem_type = type->SimdVector.elem;
+ if (!build_context.use_llvm_api) {
+ error(call, "'swizzle' with #simd vector is not supported on this backend");
+ }
+ }
i64 arg_count = 0;
for_array(i, ce->args) {