diff options
| author | gingerBill <bill@gingerbill.org> | 2023-09-06 17:33:38 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-09-06 17:33:38 +0100 |
| commit | aaaff9b66ca10edd9cf76bb24463a7b16095325e (patch) | |
| tree | c984778e1b98bf8c1ebc4728fc6290202091f050 /src/check_expr.cpp | |
| parent | c660b43105f34d54192527f2d052346213702dfa (diff) | |
Fix bug: Disallow non-specialized polymorphic in typeid assignment
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index a0d3c24bf..abcb7fd72 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -629,6 +629,9 @@ gb_internal i64 check_distance_between_types(CheckerContext *c, Operand *operand if (operand->mode == Addressing_Type) { if (is_type_typeid(type)) { + if (is_type_polymorphic(operand->type)) { + return -1; + } add_type_info_type(c, operand->type); return 4; } @@ -1118,10 +1121,17 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ LIT(context_name)); break; case Addressing_Type: - error(operand->expr, - "Cannot assign '%s' which is a type in %.*s", - op_type_str, - LIT(context_name)); + if (is_type_polymorphic(operand->type)) { + error(operand->expr, + "Cannot assign '%s' which is a polymorphic type in %.*s", + op_type_str, + LIT(context_name)); + } else { + error(operand->expr, + "Cannot assign '%s' which is a type in %.*s", + op_type_str, + LIT(context_name)); + } break; default: // TODO(bill): is this a good enough error message? |