- x'1234' +++ (ichar[1]) { 'A' } would fail due to missing const folding.

This commit is contained in:
Christoffer Lerno
2025-12-30 16:06:28 +01:00
parent 493a084745
commit 5ed4f9519f
3 changed files with 10 additions and 0 deletions

View File

@@ -42,6 +42,7 @@
- Assert when encountering a malformed module alias. - Assert when encountering a malformed module alias.
- Assert when encountering a test function with raw vaarg parameters. - Assert when encountering a test function with raw vaarg parameters.
- `foo.x` was not always handled correctly when `foo` was optional. - `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 ### Stdlib changes
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads. - Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.

View File

@@ -187,6 +187,10 @@ static bool sema_concat_bytes_and_other(SemaContext *context, Expr *expr, Expr *
case CONST_SLICE: case CONST_SLICE:
case CONST_INITIALIZER: case CONST_INITIALIZER:
if (!cast_implicit(context, right, type_get_inferred_array(indexed), false)) return false; 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); expr_contract_array(&right->const_expr, left->const_expr.const_kind);
goto RETRY; goto RETRY;
} }

View File

@@ -0,0 +1,5 @@
fn int main()
{
const A = x'1234' +++ (ichar[1]) { 'A' };
return 0;
}