diff --git a/releasenotes.md b/releasenotes.md index c1f54cac9..18f20f55c 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -42,6 +42,7 @@ - Assert when encountering a malformed module alias. - Assert when encountering a test function with raw vaarg parameters. - `foo.x` was not always handled correctly when `foo` was optional. +- `x'1234' +++ (ichar[1]) { 'A' }` would fail due to missing const folding. ### Stdlib changes - Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads. diff --git a/src/compiler/sema_const.c b/src/compiler/sema_const.c index 0adea99f9..40bffc232 100644 --- a/src/compiler/sema_const.c +++ b/src/compiler/sema_const.c @@ -187,6 +187,10 @@ static bool sema_concat_bytes_and_other(SemaContext *context, Expr *expr, Expr * case CONST_SLICE: case CONST_INITIALIZER: if (!cast_implicit(context, right, type_get_inferred_array(indexed), false)) return false; + if (!sema_cast_const(right)) + { + RETURN_SEMA_ERROR(right, "Could not concatenate with the right hand side."); + } expr_contract_array(&right->const_expr, left->const_expr.const_kind); goto RETRY; } diff --git a/test/test_suite/compile_time/concat_convert.c3 b/test/test_suite/compile_time/concat_convert.c3 new file mode 100644 index 000000000..910e0d888 --- /dev/null +++ b/test/test_suite/compile_time/concat_convert.c3 @@ -0,0 +1,5 @@ +fn int main() +{ + const A = x'1234' +++ (ichar[1]) { 'A' }; + return 0; +}