aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-03-26 15:13:51 +0300
committerVeikka Tuominen <git@vexu.eu>2023-03-26 15:14:03 +0300
commit4a5628e7306a242ce0d2f14f09eaf17ad4ae87b2 (patch)
tree9b862cb1efa33705e150c306e6a40b1c7c9dd08a /src/Module.zig
parent3a7fe0d0105ed69354960896a5d9eadd9dee3563 (diff)
downloadzig-4a5628e7306a242ce0d2f14f09eaf17ad4ae87b2.tar.gz
zig-4a5628e7306a242ce0d2f14f09eaf17ad4ae87b2.zip
Module: fix lazy srcloc resolution for new for loop syntax
Closes #15081
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 906bde95c7..9dab3edccd 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -2459,7 +2459,7 @@ pub const SrcLoc = struct {
return nodeToSpan(tree, node_datas[asm_output].lhs);
},
- .node_offset_for_cond, .node_offset_if_cond => |node_off| {
+ .node_offset_if_cond => |node_off| {
const tree = try src_loc.file_scope.getTree(gpa);
const node = src_loc.declRelativeToNodeIndex(node_off);
const node_tags = tree.nodes.items(.tag);
@@ -2471,9 +2471,16 @@ pub const SrcLoc = struct {
.while_simple,
.while_cont,
.@"while",
+ => tree.fullWhile(node).?.ast.cond_expr,
+
.for_simple,
.@"for",
- => tree.fullWhile(node).?.ast.cond_expr,
+ => {
+ const inputs = tree.fullFor(node).?.ast.inputs;
+ const start = tree.firstToken(inputs[0]);
+ const end = tree.lastToken(inputs[inputs.len - 1]);
+ return tokensToSpan(tree, start, end, start);
+ },
.@"orelse" => node,
.@"catch" => node,
@@ -2967,12 +2974,6 @@ pub const LazySrcLoc = union(enum) {
/// The source location points to the initializer of a var decl.
/// The Decl is determined contextually.
node_offset_var_decl_init: i32,
- /// The source location points to a for loop condition expression,
- /// found by taking this AST node index offset from the containing
- /// Decl AST node, which points to a for loop AST node. Next, navigate
- /// to the condition expression.
- /// The Decl is determined contextually.
- node_offset_for_cond: i32,
/// The source location points to the first parameter of a builtin
/// function call, found by taking this AST node index offset from the containing
/// Decl AST node, which points to a builtin call AST node. Next, navigate
@@ -3233,7 +3234,6 @@ pub const LazySrcLoc = union(enum) {
.node_offset_var_decl_section,
.node_offset_var_decl_addrspace,
.node_offset_var_decl_init,
- .node_offset_for_cond,
.node_offset_builtin_call_arg0,
.node_offset_builtin_call_arg1,
.node_offset_builtin_call_arg2,