diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-12-24 11:19:46 +0100 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2020-12-24 15:57:12 +0200 |
| commit | e18abab55aea4a5c3b347274e41de9fdc24e950c (patch) | |
| tree | fdf2716108151ffcddde84eaf5431fb27fbfac5f /src | |
| parent | 83646df2cce59f254822355ec1ceeb6884e1177e (diff) | |
| download | zig-e18abab55aea4a5c3b347274e41de9fdc24e950c.tar.gz zig-e18abab55aea4a5c3b347274e41de9fdc24e950c.zip | |
stage1: Create a new declaration scope for union enum types
Making the enum type share the scope with the parent union means every
declaration "bleeds" into the enum scope.
Let's mint a fresh empty scope for the enum type.
Thanks to @Vexu for the test case.
Closes #7532
Diffstat (limited to 'src')
| -rw-r--r-- | src/stage1/analyze.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/stage1/analyze.cpp b/src/stage1/analyze.cpp index 40a294e8d8..fd82a30ce0 100644 --- a/src/stage1/analyze.cpp +++ b/src/stage1/analyze.cpp @@ -3281,7 +3281,8 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { tag_type->data.enumeration.src_field_count = field_count; tag_type->data.enumeration.fields = heap::c_allocator.allocate<TypeEnumField>(field_count); tag_type->data.enumeration.fields_by_name.init(field_count); - tag_type->data.enumeration.decls_scope = union_type->data.unionation.decls_scope; + tag_type->data.enumeration.decls_scope = create_decls_scope( + g, nullptr, nullptr, tag_type, get_scope_import(scope), &tag_type->name); } else if (enum_type_node != nullptr) { tag_type = analyze_type_expr(g, scope, enum_type_node); } else { |
