diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 12:26:22 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 19:17:21 -0700 |
| commit | 22965e6fcbafbcba207a6da8eb493af2cf7ef924 (patch) | |
| tree | 99f420ce5880d23f3053fbf52e977f1cf6715a83 /src/Module.zig | |
| parent | b13745ac03195c87d9efec2b12f564d4d3cbd477 (diff) | |
| download | zig-22965e6fcbafbcba207a6da8eb493af2cf7ef924.tar.gz zig-22965e6fcbafbcba207a6da8eb493af2cf7ef924.zip | |
Sema: improve error message for mismatched for loop lengths
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig index 4feb04abdd..377ccd2441 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -2462,6 +2462,13 @@ pub const SrcLoc = struct { }; return nodeToSpan(tree, src_node); }, + .for_input => |for_input| { + const tree = try src_loc.file_scope.getTree(gpa); + const node = src_loc.declRelativeToNodeIndex(for_input.for_node_offset); + const for_full = tree.fullFor(node).?; + const src_node = for_full.ast.inputs[for_input.input_index]; + return nodeToSpan(tree, src_node); + }, .node_offset_bin_lhs => |node_off| { const tree = try src_loc.file_scope.getTree(gpa); const node = src_loc.declRelativeToNodeIndex(node_off); @@ -3114,6 +3121,14 @@ pub const LazySrcLoc = union(enum) { /// The source location points to the RHS of an assignment. /// The Decl is determined contextually. node_offset_store_operand: i32, + /// The source location points to a for loop input. + /// The Decl is determined contextually. + for_input: struct { + /// Points to the for loop AST node. + for_node_offset: i32, + /// Picks one of the inputs from the condition. + input_index: u32, + }, pub const nodeOffset = if (TracedOffset.want_tracing) nodeOffsetDebug else nodeOffsetRelease; @@ -3200,6 +3215,7 @@ pub const LazySrcLoc = union(enum) { .node_offset_init_ty, .node_offset_store_ptr, .node_offset_store_operand, + .for_input, => .{ .file_scope = decl.getFileScope(), .parent_decl_node = decl.src_node, |
