@@ -1282,6 +1282,7 @@ fn arrayInitExpr(
12821282 }
12831283 }
12841284 const array_type_inst = try typeExpr (gz , scope , array_init .ast .type_expr );
1285+ _ = try gz .addUnNode (.validate_array_init_ty , array_type_inst , node );
12851286 const elem_type = try gz .addUnNode (.elem_type , array_type_inst , array_init .ast .type_expr );
12861287 break :inst .{
12871288 .array = array_type_inst ,
@@ -1495,8 +1496,10 @@ fn structInitExpr(
14951496 switch (rl ) {
14961497 .discard = > {
14971498 // TODO if a type expr is given the fields should be validated for that type
1498- if (struct_init .ast .type_expr != 0 )
1499- _ = try typeExpr (gz , scope , struct_init .ast .type_expr );
1499+ if (struct_init .ast .type_expr != 0 ) {
1500+ const ty_inst = try typeExpr (gz , scope , struct_init .ast .type_expr );
1501+ _ = try gz .addUnNode (.validate_struct_init_ty , ty_inst , node );
1502+ }
15001503 for (struct_init .ast .fields ) | field_init | {
15011504 _ = try expr (gz , scope , .discard , field_init );
15021505 }
@@ -1505,6 +1508,7 @@ fn structInitExpr(
15051508 .ref = > {
15061509 if (struct_init .ast .type_expr != 0 ) {
15071510 const ty_inst = try typeExpr (gz , scope , struct_init .ast .type_expr );
1511+ _ = try gz .addUnNode (.validate_struct_init_ty , ty_inst , node );
15081512 return structInitExprRlTy (gz , scope , node , struct_init , ty_inst , .struct_init_ref );
15091513 } else {
15101514 return structInitExprRlNone (gz , scope , node , struct_init , .struct_init_anon_ref );
@@ -1513,6 +1517,7 @@ fn structInitExpr(
15131517 .none = > {
15141518 if (struct_init .ast .type_expr != 0 ) {
15151519 const ty_inst = try typeExpr (gz , scope , struct_init .ast .type_expr );
1520+ _ = try gz .addUnNode (.validate_struct_init_ty , ty_inst , node );
15161521 return structInitExprRlTy (gz , scope , node , struct_init , ty_inst , .struct_init );
15171522 } else {
15181523 return structInitExprRlNone (gz , scope , node , struct_init , .struct_init_anon );
@@ -1523,6 +1528,7 @@ fn structInitExpr(
15231528 return structInitExprRlTy (gz , scope , node , struct_init , ty_inst , .struct_init );
15241529 }
15251530 const inner_ty_inst = try typeExpr (gz , scope , struct_init .ast .type_expr );
1531+ _ = try gz .addUnNode (.validate_struct_init_ty , inner_ty_inst , node );
15261532 const result = try structInitExprRlTy (gz , scope , node , struct_init , inner_ty_inst , .struct_init );
15271533 return rvalue (gz , rl , result , node );
15281534 },
@@ -1573,6 +1579,7 @@ fn structInitExprRlPtr(
15731579 return structInitExprRlPtrInner (gz , scope , node , struct_init , base_ptr );
15741580 }
15751581 const ty_inst = try typeExpr (gz , scope , struct_init .ast .type_expr );
1582+ _ = try gz .addUnNode (.validate_struct_init_ty , ty_inst , node );
15761583
15771584 var as_scope = try gz .makeCoercionScope (scope , ty_inst , result_ptr );
15781585 defer as_scope .unstack ();
@@ -2334,6 +2341,8 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner
23342341 .closure_capture ,
23352342 .memcpy ,
23362343 .memset ,
2344+ .validate_array_init_ty ,
2345+ .validate_struct_init_ty ,
23372346 = > break :b true ,
23382347 }
23392348 } else switch (maybe_unused_result ) {
0 commit comments