From fbb4ae056ad7b0b975732283016a6be298512763 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sat, 11 Jan 2025 01:02:13 +0100 Subject: [PATCH] Bug when using +++ on value build a slice or array: the rhs cast was not done, corrupting data. --- releasenotes.md | 1 + src/compiler/sema_const.c | 1 + 2 files changed, 2 insertions(+) diff --git a/releasenotes.md b/releasenotes.md index 5844cdf5b..04d0b6f93 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -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. diff --git a/src/compiler/sema_const.c b/src/compiler/sema_const.c index 22d14aecb..7aa182d2c 100644 --- a/src/compiler/sema_const.c +++ b/src/compiler/sema_const.c @@ -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)