Skip to content

Commit ea6c052

Browse files
fix null value crash in analysis.zig (#2252)
1 parent 3242204 commit ea6c052

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/analysis.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ fn resolveTypeOfNodeUncached(analyser: *Analyser, node_handle: NodeWithHandle) e
16431643
const ptyp = try analyser.arena.allocator().create(Type);
16441644
ptyp.* = argument_type;
16451645

1646-
const symbol = offsets.identifierTokenToNameSlice(func_tree, param.name_token.?);
1646+
const symbol = if (param.name_token) |name_token| offsets.identifierTokenToNameSlice(func_tree, name_token) else "";
16471647
meta_params.appendAssumeCapacity(.{ .index = param_index, .symbol = symbol, .typ = ptyp });
16481648
}
16491649

tests/lsp_features/completion.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,14 @@ test "recursive generic function" {
422422
, &.{});
423423
}
424424

425+
test "generic function without body" {
426+
try testCompletion(
427+
\\const Foo: fn (type) type = undefined;
428+
\\const Bar = Foo(u32);
429+
\\const value = Bar.<cursor>;
430+
, &.{});
431+
}
432+
425433
test "std.ArrayList" {
426434
if (!std.process.can_spawn) return error.SkipZigTest;
427435
try testCompletion(

0 commit comments

Comments
 (0)