mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
stage2: fix crash on file-level struct field source locations
This commit is contained in:
parent
b463924da2
commit
50accb757f
@ -1642,6 +1642,18 @@ pub fn containerDeclArg(tree: Ast, node: Node.Index) full.ContainerDecl {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn containerDeclRoot(tree: Ast) full.ContainerDecl {
|
||||
return .{
|
||||
.layout_token = null,
|
||||
.ast = .{
|
||||
.main_token = undefined,
|
||||
.enum_token = null,
|
||||
.members = tree.rootDecls(),
|
||||
.arg = 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
pub fn taggedUnionTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
|
||||
assert(tree.nodes.items(.tag)[node] == .tagged_union_two or
|
||||
tree.nodes.items(.tag)[node] == .tagged_union_two_trailing);
|
||||
|
||||
@ -131,20 +131,11 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
|
||||
};
|
||||
defer gz_instructions.deinit(gpa);
|
||||
|
||||
const container_decl: Ast.full.ContainerDecl = .{
|
||||
.layout_token = null,
|
||||
.ast = .{
|
||||
.main_token = undefined,
|
||||
.enum_token = null,
|
||||
.members = tree.rootDecls(),
|
||||
.arg = 0,
|
||||
},
|
||||
};
|
||||
if (AstGen.structDeclInner(
|
||||
&gen_scope,
|
||||
&gen_scope.base,
|
||||
0,
|
||||
container_decl,
|
||||
tree.containerDeclRoot(),
|
||||
.Auto,
|
||||
)) |struct_decl_ref| {
|
||||
assert(refToIndex(struct_decl_ref).? == 0);
|
||||
|
||||
@ -935,6 +935,8 @@ pub const Struct = struct {
|
||||
.tagged_union_enum_tag_trailing,
|
||||
=> return queryFieldSrc(tree.*, query, file, tree.taggedUnionEnumTag(node)),
|
||||
|
||||
.root => return queryFieldSrc(tree.*, query, file, tree.containerDeclRoot()),
|
||||
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user