Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/analysis.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ fn resolveTypeOfNodeUncached(analyser: *Analyser, node_handle: NodeWithHandle) e
.unwrap_optional => try analyser.resolveOptionalUnwrap(base_type),
.array_access => try analyser.resolveBracketAccessType(base_type, .Single),
.@"orelse" => {
const type_right = try analyser.resolveTypeOfNodeInternal(.{ .node = datas[node].rhs, .handle = handle }) orelse return null;
const type_right = try analyser.resolveTypeOfNodeInternal(.{ .node = datas[node].rhs, .handle = handle }) orelse return try analyser.resolveOptionalUnwrap(base_type);
return try analyser.resolveOrelseType(base_type, type_right);
},
.@"catch" => try analyser.resolveUnwrapErrorUnionType(base_type, .payload),
Expand Down
18 changes: 18 additions & 0 deletions tests/lsp_features/completion.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2529,6 +2529,24 @@ test "@extern" {
});
}

test "@orelse with block" {
try testCompletion(
\\test {
\\ const S = struct {
\\ alpha: u32,
\\ };
\\ const v: ?*const S = &S{ .alpha = 5 };
\\ const foo = v orelse {
\\ return;
\\ };
\\ foo.<cursor>
\\}
, &.{
.{ .label = "*", .kind = .Operator, .detail = "S" },
.{ .label = "alpha", .kind = .Field, .detail = "u32" },
});
}

test "builtin fns return type" {
try testCompletion(
\\pub const chip_mod = struct {
Expand Down