Module: fix lazy srcloc resolution for new for loop syntax
Closes #15081
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user