mirror of
https://github.com/ziglang/zig.git
synced 2024-12-15 07:40:13 +00:00
stage2: fix unreachable in union(enum) with anytype payload
This commit is contained in:
parent
3be682bac9
commit
ef56e42a2a
@ -3835,7 +3835,7 @@ fn unionDeclInner(
|
||||
if (member.comptime_token) |comptime_token| {
|
||||
return astgen.failTok(comptime_token, "union fields cannot be marked comptime", .{});
|
||||
}
|
||||
try fields_data.ensureUnusedCapacity(gpa, 4);
|
||||
try fields_data.ensureUnusedCapacity(gpa, if (node_tags[member.ast.type_expr] != .@"anytype") 4 else 3);
|
||||
|
||||
const field_name = try astgen.identAsString(member.ast.name_token);
|
||||
fields_data.appendAssumeCapacity(field_name);
|
||||
@ -3850,7 +3850,7 @@ fn unionDeclInner(
|
||||
(@as(u32, @boolToInt(have_value)) << 30) |
|
||||
(@as(u32, @boolToInt(unused)) << 31);
|
||||
|
||||
if (have_type) {
|
||||
if (have_type and node_tags[member.ast.type_expr] != .@"anytype") {
|
||||
const field_type = try typeExpr(&block_scope, &block_scope.base, member.ast.type_expr);
|
||||
fields_data.appendAssumeCapacity(@enumToInt(field_type));
|
||||
}
|
||||
|
@ -811,3 +811,7 @@ test "union enum type gets a separate scope" {
|
||||
|
||||
try S.doTheTest();
|
||||
}
|
||||
test "anytype union field: issue #9233" {
|
||||
const Baz = union(enum) { bar: anytype };
|
||||
_ = Baz;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user