diff options
| author | gingerBill <bill@gingerbill.org> | 2022-07-24 12:59:34 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-07-24 12:59:34 +0100 |
| commit | 9f10487678e6adcb654eadb75b08eb731090c2ec (patch) | |
| tree | 28a95e1d4295e955f94fa0d5888e942682658c6e /src/check_expr.cpp | |
| parent | 2542983d709ced71e0aca9e67909b91c70d33baa (diff) | |
Fix #1493
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 721b5a5af..ff1745535 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -2959,7 +2959,14 @@ void check_binary_matrix(CheckerContext *c, Token const &op, Operand *x, Operand goto matrix_error; } x->mode = Addressing_Value; - x->type = alloc_type_matrix(xt->Matrix.elem, xt->Matrix.row_count, yt->Matrix.column_count); + if (are_types_identical(xt, yt)) { + if (!is_type_named(x->type) && is_type_named(y->type)) { + // prefer the named type + x->type = y->type; + } + } else { + x->type = alloc_type_matrix(xt->Matrix.elem, xt->Matrix.row_count, yt->Matrix.column_count); + } goto matrix_success; } else if (yt->kind == Type_Array) { if (!are_types_identical(xt->Matrix.elem, yt->Array.elem)) { @@ -3021,7 +3028,6 @@ void check_binary_matrix(CheckerContext *c, Token const &op, Operand *x, Operand matrix_success: x->type = check_matrix_type_hint(x->type, type_hint); - return; |