From 989107094c64b6f74dadb40df2374a9db625778a Mon Sep 17 00:00:00 2001 From: Jasper Geer Date: Fri, 21 Oct 2022 15:41:58 -0400 Subject: [PATCH] throw type checker error when scalar cast to non-square matrix --- src/check_expr.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index ab5838bf5..b3c04caa4 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -821,11 +821,12 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type if (are_types_identical(src, dst)) { return 5; } - - Type *dst_elem = base_array_type(dst); - i64 distance = check_distance_between_types(c, operand, dst_elem); - if (distance >= 0) { - return distance + 7; + if (dst->Matrix.row_count == dst->Matrix.column_count) { + Type *dst_elem = base_array_type(dst); + i64 distance = check_distance_between_types(c, operand, dst_elem); + if (distance >= 0) { + return distance + 7; + } } }