From 0153f3a8f9b93ebef7b5cd70db8560fcac658ce7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 18 Jul 2023 17:12:19 -0700 Subject: Sema: fix crash: array_in_c_exported_function Fuck it, we're storing decl indexes in LazySrcLoc now. --- src/Module.zig | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index d9ee3a57ad..3ae78c30b1 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -1821,8 +1821,8 @@ pub const SrcLoc = struct { return tree.firstToken(src_loc.parent_decl_node); } - pub fn declRelativeToNodeIndex(src_loc: SrcLoc, offset: i32) Ast.TokenIndex { - return @as(Ast.Node.Index, @bitCast(offset + @as(i32, @bitCast(src_loc.parent_decl_node)))); + pub fn declRelativeToNodeIndex(src_loc: SrcLoc, offset: i32) Ast.Node.Index { + return @bitCast(offset + @as(i32, @bitCast(src_loc.parent_decl_node))); } pub const Span = struct { @@ -2829,14 +2829,15 @@ pub const LazySrcLoc = union(enum) { /// The Decl is determined contextually. for_capture_from_input: i32, /// The source location points to the argument node of a function call. - /// The Decl is determined contextually. call_arg: struct { + decl: Decl.Index, /// Points to the function call AST node. call_node_offset: i32, /// The index of the argument the source location points to. arg_index: u32, }, fn_proto_param: struct { + decl: Decl.Index, /// Points to the function prototype AST node. fn_proto_node_offset: i32, /// The index of the parameter the source location points to. @@ -2931,13 +2932,18 @@ pub const LazySrcLoc = union(enum) { .node_offset_store_operand, .for_input, .for_capture_from_input, - .call_arg, - .fn_proto_param, => .{ .file_scope = decl.getFileScope(mod), .parent_decl_node = decl.src_node, .lazy = lazy, }, + inline .call_arg, + .fn_proto_param, + => |x| .{ + .file_scope = decl.getFileScope(mod), + .parent_decl_node = mod.declPtr(x.decl).src_node, + .lazy = lazy, + }, }; } }; -- cgit v1.2.3