Commit 6754d1a182

Andrew Kelley <andrew@ziglang.org>
2023-07-15 08:16:17
Sema: fix access of inactive union field
When instantiating a generic function call, in the case of a function call generated by the language, the LazySrcLoc provided for `call_src` may not point to anything interesting.
1 parent 9f61c29
Changed files (1)
src/Sema.zig
@@ -7569,13 +7569,14 @@ fn instantiateGenericCall(
     {
         var runtime_i: u32 = 0;
         for (uncasted_args, 0..) |uncasted_arg, total_i| {
+            // In the case of a function call generated by the language, the LazySrcLoc
+            // provided for `call_src` may not point to anything interesting.
             const arg_src: LazySrcLoc = if (total_i == 0 and bound_arg_src != null)
                 bound_arg_src.?
-            else
-                .{ .call_arg = .{
-                    .call_node_offset = call_src.node_offset.x,
-                    .arg_index = @intCast(total_i),
-                } };
+            else if (call_src == .node_offset) .{ .call_arg = .{
+                .call_node_offset = call_src.node_offset.x,
+                .arg_index = @intCast(total_i),
+            } } else .unneeded;
 
             const comptime_arg = callee.comptime_args.get(ip)[total_i];
             if (comptime_arg == .none) {