authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-14 23:16:17-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-18 19:02:06-07:00
log6754d1a1826615886b933a7de207d1d97720ae53
tree89048702967e76308bcf6799c931edf5b45bbf54
parent9f61c29bfb8f9a93f737a099ed38f9e0a106d6b6

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 files changed, 6 insertions(+), 5 deletions(-)

src/Sema.zig+6-5
......@@ -7569,13 +7569,14 @@ fn instantiateGenericCall(
75697569 {
75707570 var runtime_i: u32 = 0;
75717571 for (uncasted_args, 0..) |uncasted_arg, total_i| {
7572 // In the case of a function call generated by the language, the LazySrcLoc
7573 // provided for `call_src` may not point to anything interesting.
75727574 const arg_src: LazySrcLoc = if (total_i == 0 and bound_arg_src != null)
75737575 bound_arg_src.?
7574 else
7575 .{ .call_arg = .{
7576 .call_node_offset = call_src.node_offset.x,
7577 .arg_index = @intCast(total_i),
7578 } };
7576 else if (call_src == .node_offset) .{ .call_arg = .{
7577 .call_node_offset = call_src.node_offset.x,
7578 .arg_index = @intCast(total_i),
7579 } } else .unneeded;
75797580
75807581 const comptime_arg = callee.comptime_args.get(ip)[total_i];
75817582 if (comptime_arg == .none) {