From d515d37934476365929401a0ba7e5639b09a648a Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Wed, 24 Aug 2022 15:26:49 +0300 Subject: [PATCH] AstGen: make root decls relative to beginning of file Closes #12610 --- src/AstGen.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/AstGen.zig b/src/AstGen.zig index 2001e6950a..db0ed47a04 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -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 => {