Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/features/references.zig
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,18 @@ const Builder = struct {
var buffer: [2]Ast.Node.Index = undefined;
const struct_init = tree.fullStructInit(&buffer, node).?;

const container_type = try builder.analyser.resolveDeclLiteralExpressionType(
handle,
node,
ancestors,
) orelse return;

for (struct_init.ast.fields) |value_node| { // the node of `value` in `.name = value`
const name_token = tree.firstToken(value_node) - 2; // math our way two token indexes back to get the `name`
const name = offsets.identifierTokenToNameSlice(tree, name_token);
if (!std.mem.eql(u8, name, builder.target_symbol_name)) continue;

const candidate = try container_type.lookupSymbol(builder.analyser, name) orelse continue;
const container_type = try builder.analyser.resolveDeclLiteralExpressionType(
handle,
node,
ancestors,
) orelse return;
const candidate = try container_type.lookupSymbol(builder.analyser, name) orelse return;

// if we get here then we know that the name of the field matched
// and duplicate fields are invalid so just return early
break :candidate .{ candidate, name_token };
}
return;
Expand Down
Loading