mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Incorrect zero analysis on foo["test"] = {} #1360
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
- Issues with wincrt linking.
|
||||
- Debug info with recursive canonical type usage could cause segfault.
|
||||
- Missing check on optional left hand side for `s.x`.
|
||||
- Incorrect zero analysis on `foo["test"] = {}` #1360.
|
||||
|
||||
### Stdlib changes
|
||||
|
||||
|
||||
@@ -473,6 +473,10 @@ static inline bool sema_expr_analyse_initializer(SemaContext *context, Type *ass
|
||||
return sema_expr_analyse_designated_initializer(context, assigned_type, flattened, expr);
|
||||
}
|
||||
|
||||
if (expr->expr_kind == EXPR_CONST)
|
||||
{
|
||||
return cast_implicit(context, expr, assigned_type, false);
|
||||
}
|
||||
assert(expr->expr_kind == EXPR_INITIALIZER_LIST);
|
||||
|
||||
// 2. Grab the expressions inside.
|
||||
@@ -689,7 +693,8 @@ bool sema_expr_analyse_initializer_list(SemaContext *context, Type *to, Expr *ex
|
||||
if (!to) to = type_untypedlist;
|
||||
assert(to);
|
||||
Type *flattened = type_flatten(to);
|
||||
bool is_zero_init = expr->expr_kind == EXPR_INITIALIZER_LIST && !vec_size(expr->initializer_list);
|
||||
bool is_zero_init = (expr->expr_kind == EXPR_INITIALIZER_LIST && !vec_size(expr->initializer_list)) || sema_initializer_list_is_empty(expr);
|
||||
|
||||
if (!sema_resolve_type_structure(context, to, expr->span)) return false;
|
||||
switch (flattened->type_kind)
|
||||
{
|
||||
|
||||
12
test/test_suite/struct/const_zero_init_1360.c3t
Normal file
12
test/test_suite/struct/const_zero_init_1360.c3t
Normal file
@@ -0,0 +1,12 @@
|
||||
module test;
|
||||
import std::collections::map;
|
||||
|
||||
fn void main()
|
||||
{
|
||||
HashMap(<String, String>) map;
|
||||
map["c3c"] = {};
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user