diff --git a/src/analysis.zig b/src/analysis.zig index b56fa901f..b8a31bcc8 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -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), diff --git a/tests/lsp_features/completion.zig b/tests/lsp_features/completion.zig index c1be4d3b8..1c9502871 100644 --- a/tests/lsp_features/completion.zig +++ b/tests/lsp_features/completion.zig @@ -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. + \\} + , &.{ + .{ .label = "*", .kind = .Operator, .detail = "S" }, + .{ .label = "alpha", .kind = .Field, .detail = "u32" }, + }); +} + test "builtin fns return type" { try testCompletion( \\pub const chip_mod = struct {