aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-11-04 16:50:59 +0000
committergingerBill <bill@gingerbill.org>2021-11-04 16:50:59 +0000
commit68046d0c088d7acd90c8e0024b587d9e64ac06d2 (patch)
tree6d3806b86158e8749e0ff8addc16ae903f8bf242 /src/check_expr.cpp
parentbc2bf1caeba5cca828318d1547e214f785e2d71a (diff)
Allow casting between matrix types of different element types
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 6c85ae43a..2ad3cc4a6 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -659,8 +659,8 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type
}
if (is_type_matrix(dst)) {
- Type *elem = base_array_type(dst);
- i64 distance = check_distance_between_types(c, operand, elem);
+ Type *dst_elem = base_array_type(dst);
+ i64 distance = check_distance_between_types(c, operand, dst_elem);
if (distance >= 0) {
return distance + 7;
}
@@ -2467,7 +2467,9 @@ bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y) {
if (is_type_matrix(src) && is_type_matrix(dst)) {
GB_ASSERT(src->kind == Type_Matrix);
GB_ASSERT(dst->kind == Type_Matrix);
- if (!are_types_identical(src->Matrix.elem, dst->Matrix.elem)) {
+ Operand op = *operand;
+ op.type = src->Matrix.elem;
+ if (!check_is_castable_to(c, &op, dst->Matrix.elem)) {
return false;
}
@@ -2477,11 +2479,7 @@ bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y) {
return src_count == dst_count;
}
- if (dst->Matrix.row_count != dst->Matrix.column_count) {
- return false;
- }
-
- return true;
+ return is_matrix_square(dst) && is_matrix_square(src);
}