Bug when using +++ on value build a slice or array: the rhs cast was not done, corrupting data.

This commit is contained in:
Christoffer Lerno
2025-01-11 01:02:13 +01:00
parent ae10ae6847
commit fbb4ae056a
2 changed files with 2 additions and 0 deletions

View File

@@ -72,6 +72,7 @@
- Deref subscripts as needed for macro ref method arguments. #1789
- Change ordering to simplify adding methods to type in conditional modules.
- `#foo` style arguments were not type checked when given a type. #1790
- Bug when using +++ on value build a slice or array: the rhs cast was not done.
### Stdlib changes
- Increase BitWriter.write_bits limit up to 32 bits.

View File

@@ -243,6 +243,7 @@ static bool sema_append_const_array_one(SemaContext *context, Expr *expr, Expr *
ConstInitializer *init = is_slice ? list->const_expr.slice_init : list->const_expr.initializer;
unsigned len = sema_len_from_const(list) + 1;
Type *indexed = type_get_indexed_type(init->type);
if (!cast_implicit(context, element, indexed, false)) return false;
Type *new_inner_type = is_vector ? type_get_vector(indexed, len) : type_get_array(indexed, len);
Type *new_outer_type = list->type;
if (!is_slice)