Skip to content

Commit

Permalink
fix decl literal detection for pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
xdBronch authored and Techatrix committed Feb 9, 2025
1 parent 4b4aafc commit fd31687
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/analysis.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2781,6 +2781,7 @@ pub const Type = struct {
result_type = switch (result_type.data) {
.optional => |child_ty| child_ty.*,
.error_union => |info| info.payload.*,
.pointer => |child_ty| child_ty.elem_ty.*,
else => return result_type,
};
}
Expand Down
10 changes: 7 additions & 3 deletions tests/lsp_features/completion.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1546,18 +1546,22 @@ test "decl literal" {
\\ field: u32,
\\
\\ pub const foo: error{OutOfMemory}!S = .{};
\\ var bar: @This() = .{};
\\ var baz: u32 = .{};
\\ const bar: *const S = &.{};
\\ var baz: @This() = .{};
\\ var qux: u32 = .{};
\\
\\ fn init() ?S {}
\\ fn create() !*S {}
\\ fn func() void {}
\\};
\\const s: S = .<cursor>;
, &.{
.{ .label = "field", .kind = .Field, .detail = "u32" },
.{ .label = "foo", .kind = .Constant },
.{ .label = "bar", .kind = .Struct },
.{ .label = "bar", .kind = .Constant },
.{ .label = "baz", .kind = .Struct },
.{ .label = "init", .kind = .Function, .detail = "fn () ?S" },
.{ .label = "create", .kind = .Function, .detail = "fn () !*S" },
});
}

Expand Down

0 comments on commit fd31687

Please sign in to comment.