Fix where designated initializers had optional arguments. See #923

This commit is contained in:
Christoffer Lerno
2023-08-13 20:57:50 +02:00
parent 3c8bbc2b90
commit f912e53038
4 changed files with 16 additions and 3 deletions

View File

@@ -154,6 +154,7 @@
- Added posix socket functions.
### Fixes
- Fix issue of designated initializers that had optional arguments.
- Fixed ++ and -- for bitstructs.
- Fix to bug where library source files were sometimes ignored.
- Types of arrays and vectors are consistently checked to be valid.

View File

@@ -426,14 +426,16 @@ static bool sema_expr_analyse_designated_initializer(SemaContext *context, Type
continue;
}
}
Type *type;
if (!is_structlike && is_inferred)
{
initializer->type = type_from_inferred(flattened, type_get_indexed_type(assigned), (ArraySize)(max_index + 1));
type = type_from_inferred(flattened, type_get_indexed_type(assigned), (ArraySize)(max_index + 1));
}
else
{
initializer->type = assigned;
type = assigned;
}
initializer->type = type_add_optional(type, optional);
initializer->resolve_status = RESOLVE_DONE;
if (expr_is_constant_eval(initializer, env_eval_type(context)))
{

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.4.607"
#define COMPILER_VERSION "0.4.608"

View File

@@ -0,0 +1,10 @@
module foo;
struct Foo { int a; }
struct Bar { int b; Foo f; }
fn void! main()
{
Bar { .f = Foo { foo() } }; // #error: not be discarded
}
fn int! foo() => 1;