| ... | @@ -4155,6 +4155,8 @@ fn unionDeclInner( | ... | @@ -4155,6 +4155,8 @@ fn unionDeclInner( |
| 4155 | else | 4155 | else |
| 4156 | try typeExpr(&block_scope, &namespace.base, member.ast.type_expr); | 4156 | try typeExpr(&block_scope, &namespace.base, member.ast.type_expr); |
| 4157 | fields_data.appendAssumeCapacity(@enumToInt(field_type)); | 4157 | fields_data.appendAssumeCapacity(@enumToInt(field_type)); |
| | 4158 | } else if (arg_inst == .none and !have_auto_enum) { |
| | 4159 | return astgen.failNode(member_node, "union field missing type", .{}); |
| 4158 | } | 4160 | } |
| 4159 | if (have_align) { | 4161 | if (have_align) { |
| 4160 | const align_inst = try expr(&block_scope, &block_scope.base, .{ .ty = .u32_type }, member.ast.align_expr); | 4162 | const align_inst = try expr(&block_scope, &block_scope.base, .{ .ty = .u32_type }, member.ast.align_expr); |
| ... | @@ -4175,6 +4177,20 @@ fn unionDeclInner( | ... | @@ -4175,6 +4177,20 @@ fn unionDeclInner( |
| 4175 | }, | 4177 | }, |
| 4176 | ); | 4178 | ); |
| 4177 | } | 4179 | } |
| | 4180 | if (!have_auto_enum) { |
| | 4181 | return astgen.failNodeNotes( |
| | 4182 | node, |
| | 4183 | "explicitly valued tagged union requires inferred enum tag type", |
| | 4184 | .{}, |
| | 4185 | &[_]u32{ |
| | 4186 | try astgen.errNoteNode( |
| | 4187 | member.ast.value_expr, |
| | 4188 | "tag value specified here", |
| | 4189 | .{}, |
| | 4190 | ), |
| | 4191 | }, |
| | 4192 | ); |
| | 4193 | } |
| 4178 | const tag_value = try expr(&block_scope, &block_scope.base, .{ .ty = arg_inst }, member.ast.value_expr); | 4194 | const tag_value = try expr(&block_scope, &block_scope.base, .{ .ty = arg_inst }, member.ast.value_expr); |
| 4179 | fields_data.appendAssumeCapacity(@enumToInt(tag_value)); | 4195 | fields_data.appendAssumeCapacity(@enumToInt(tag_value)); |
| 4180 | } | 4196 | } |