mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix where designated initializers had optional arguments. See #923
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)))
|
||||
{
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define COMPILER_VERSION "0.4.607"
|
||||
#define COMPILER_VERSION "0.4.608"
|
||||
10
test/test_suite/errors/optional_designated.c3
Normal file
10
test/test_suite/errors/optional_designated.c3
Normal 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;
|
||||
Reference in New Issue
Block a user