AstGen: make root decls relative to beginning of file

Closes #12610
This commit is contained in:
Veikka Tuominen 2022-08-24 15:26:49 +03:00
parent 38215ccc3e
commit d515d37934

View File

@ -4265,10 +4265,13 @@ fn structDeclInner(
// are in scope, so that field types, alignments, and default value expressions
// can refer to decls within the struct itself.
astgen.advanceSourceCursorToNode(node);
// If `node == 0` then this is the root struct and all the declarations should
// be relative to the beginning of the file.
const decl_line = if (node == 0) 0 else astgen.source_line;
var block_scope: GenZir = .{
.parent = &namespace.base,
.decl_node_index = node,
.decl_line = astgen.source_line,
.decl_line = decl_line,
.astgen = astgen,
.force_comptime = true,
.in_defer = false,
@ -11764,7 +11767,6 @@ fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const Ast.
}
}
// const index_name = try astgen.identAsString(index_token);
var s = namespace.parent;
while (true) switch (s.tag) {
.local_val => {