aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorg-w1 <58830309+g-w1@users.noreply.github.com>2021-06-27 05:26:29 -0400
committerGitHub <noreply@github.com>2021-06-27 12:26:29 +0300
commitef56e42a2a69e85d185257c5bd0b3f12532f2f5d (patch)
treeb0620e061d1dea8e894873ec54aee0fcacfd6f66 /src
parent3be682bac9b768ae6481ed2a07844ee8ba87a896 (diff)
downloadzig-ef56e42a2a69e85d185257c5bd0b3f12532f2f5d.tar.gz
zig-ef56e42a2a69e85d185257c5bd0b3f12532f2f5d.zip
stage2: fix unreachable in union(enum) with anytype payload
Diffstat (limited to 'src')
-rw-r--r--src/AstGen.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig
index bcfb5a45b7..4254481a55 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -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));
}