Skip to content

Commit

Permalink
resolve void value {} (#1735)
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix authored Jan 30, 2024
1 parent 63f5ad1 commit b3ad4ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/analysis.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,15 @@ fn resolveTypeOfNodeUncached(analyser: *Analyser, node_handle: NodeWithHandle) e
.block_two,
.block_two_semicolon,
=> {
const has_zero_statements = switch (node_tags[node]) {
.block_two, .block_two_semicolon => datas[node].lhs == 0,
.block, .block_semicolon => false,
else => unreachable,
};
if (has_zero_statements) {
return Type{ .data = .{ .ip_index = .{ .index = .void_value } }, .is_type_val = false };
}

const first_token = tree.firstToken(node);
if (token_tags[first_token] != .identifier) return null;

Expand Down
10 changes: 10 additions & 0 deletions tests/lsp_features/hover.zig
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ test "hover - literal" {
\\(*const [26:0]u8)
\\```
);
try testHover(
\\const f<cursor>oo = {};
,
\\```zig
\\const foo = {}
\\```
\\```zig
\\(void)
\\```
);
}

test "hover - builtin" {
Expand Down

0 comments on commit b3ad4ab

Please sign in to comment.