diff options
| author | Jasper Geer <jasper.geer@gmail.com> | 2022-10-21 15:41:58 -0400 |
|---|---|---|
| committer | Jasper Geer <jasper.geer@gmail.com> | 2022-10-21 15:41:58 -0400 |
| commit | 989107094c64b6f74dadb40df2374a9db625778a (patch) | |
| tree | 8e08edf20944db58241c0bc7852729aa767c624e /src/check_expr.cpp | |
| parent | fd8956b8f49c5b0dd36e6f519abe819536cedfc9 (diff) | |
throw type checker error when scalar cast to non-square matrix
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 11 |
1 files 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; + } } } |