Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/analysis.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5873,6 +5873,7 @@ pub fn lookupSymbolFieldInit(
const unwrapped =
try analyser.resolveUnwrapErrorUnionType(container_type, .payload) orelse
try analyser.resolveOptionalUnwrap(container_type) orelse
try analyser.resolveDerefType(container_type) orelse
break;
container_type = unwrapped;
}
Expand Down
23 changes: 23 additions & 0 deletions tests/lsp_features/definition.zig
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,29 @@ test "decl literal on generic type" {
);
}

test "decl literal pointer" {
try testDefinition(
\\const S = struct {
\\ const value: S = .{};
\\ const <def><decl>ptr</decl></def>: *const S = &value;
\\};
\\test {
\\ const ptr: *const S = .<>ptr;
\\}
);
try testDefinition(
\\const S = struct {
\\ const value: S = .{};
\\ fn <def><decl>pointerFn</decl></def>() *const S {
\\ return &value;
\\ }
\\};
\\test {
\\ const ptr: *const S = .poi<>nterFn();
\\}
);
}

test "capture" {
try testDefinition(
\\test {
Expand Down
38 changes: 38 additions & 0 deletions tests/lsp_features/hover.zig
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,44 @@ test "decl literal function" {
);
}

test "decl literal pointer" {
try testHover(
\\const S = struct {
\\ const value: S = .{};
\\ const ptr: *const S = &value;
\\};
\\const s: *const S = .pt<cursor>r;
,
\\```zig
\\const ptr: *const S = &value
\\```
\\```zig
\\(*const S)
\\```
\\
\\Go to [S](untitled:///Untitled-0.zig#L1)
);

try testHover(
\\const S = struct {
\\ const value: S = .{};
\\ fn pointerFn() *const S {
\\ return &value;
\\ }
\\};
\\const s: *const S = .poi<cursor>nterFn();
,
\\```zig
\\fn pointerFn() *const S
\\```
\\```zig
\\(fn () *const S)
\\```
\\
\\Go to [S](untitled:///Untitled-0.zig#L1)
);
}

test "decl literal on generic type" {
try testHover(
\\fn Box(comptime T: type) type {
Expand Down