ソースを参照

throw type checker error when scalar cast to non-square matrix

Jasper Geer 2 年 前
コミット
989107094c
1 ファイル変更6 行追加5 行削除
  1. 6 5
      src/check_expr.cpp

+ 6 - 5
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;
+			}
 		}
 	}