diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 13:22:29 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 19:20:19 -0700 |
| commit | 601db3981ce820cfbca6001cbdfa87e24aa35ab5 (patch) | |
| tree | fc16c4e08604482278b5a7dc6975b249af8a132f /src/Sema.zig | |
| parent | bcb72401d3cf01c190a346af9c9d8eec4a334b45 (diff) | |
| download | zig-601db3981ce820cfbca6001cbdfa87e24aa35ab5.tar.gz zig-601db3981ce820cfbca6001cbdfa87e24aa35ab5.zip | |
fix source location for not-indexable for loop errors
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 5a185a709c..7e8520eaa1 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -3929,11 +3929,15 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. .Int, .ComptimeInt => true, else => false, }; + const arg_src: LazySrcLoc = .{ .for_input = .{ + .for_node_offset = inst_data.src_node, + .input_index = i, + } }; const arg_len = if (is_int) object else l: { - try checkIndexable(sema, block, src, object_ty); + try checkIndexable(sema, block, arg_src, object_ty); if (!object_ty.indexableHasLen()) continue; - break :l try sema.fieldVal(block, src, object, "len", src); + break :l try sema.fieldVal(block, arg_src, object, "len", arg_src); }; if (len == .none) { len = arg_len; @@ -3949,14 +3953,10 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. .for_node_offset = inst_data.src_node, .input_index = len_idx, } }; - const b_src: LazySrcLoc = .{ .for_input = .{ - .for_node_offset = inst_data.src_node, - .input_index = i, - } }; try sema.errNote(block, a_src, msg, "length {} here", .{ v.fmtValue(Type.usize, sema.mod), }); - try sema.errNote(block, b_src, msg, "length {} here", .{ + try sema.errNote(block, arg_src, msg, "length {} here", .{ arg_val.fmtValue(Type.usize, sema.mod), }); break :msg msg; |
