Fix inferred error set return types
This commit is contained in:
parent
e2f4bbf2f3
commit
53c37765c0
@ -63,6 +63,7 @@ The following options are currently available.
|
||||
| `build_runner_cache_path` | `?[]const u8` | `null` | Path to a directroy that will be used as zig's cache when running `zig run build_runner.zig ...`. `null` is equivalent to `${KnownFloders.Cache}/zls` |
|
||||
| `enable_semantic_tokens` | `bool` | `true` | Enables semantic token support when the client also supports it. |
|
||||
| `operator_completions` | `bool` | `true` | Enables `*` and `?` operators in completion lists. |
|
||||
| `skip_std_references` | `bool` | `false` | When true, skips searching for references in std. Improves lookup speed for functions in user's code. Renaming and go-to-definition will continue to work as is.
|
||||
|
||||
## Features
|
||||
|
||||
|
@ -467,8 +467,24 @@ pub fn resolveReturnType(
|
||||
}
|
||||
|
||||
if (fn_decl.ast.return_type == 0) return null;
|
||||
return ((try resolveTypeOfNodeInternal(store, arena, .{
|
||||
.node = fn_decl.ast.return_type,
|
||||
const return_type = fn_decl.ast.return_type;
|
||||
|
||||
const is_inferred_error = tree.tokens.items(.tag)[tree.firstToken(return_type) - 1] == .bang;
|
||||
return if (is_inferred_error) block: {
|
||||
const child_type = (try resolveTypeOfNodeInternal(store, arena, .{
|
||||
.node = return_type,
|
||||
.handle = handle,
|
||||
}, bound_type_params)) orelse return null;
|
||||
const child_type_node = switch (child_type.type.data) {
|
||||
.other => |n| n,
|
||||
else => return null,
|
||||
};
|
||||
break :block TypeWithHandle{
|
||||
.type = .{ .data = .{ .error_union = child_type_node }, .is_type_val = false },
|
||||
.handle = child_type.handle,
|
||||
};
|
||||
} else ((try resolveTypeOfNodeInternal(store, arena, .{
|
||||
.node = return_type,
|
||||
.handle = handle,
|
||||
}, bound_type_params)) orelse return null).instanceTypeVal();
|
||||
}
|
||||
@ -509,6 +525,7 @@ fn resolveUnwrapErrorType(
|
||||
},
|
||||
.primitive, .slice, .pointer => return null,
|
||||
};
|
||||
|
||||
if (rhs.handle.tree.nodes.items(.tag)[rhs_node] == .error_union) {
|
||||
return ((try resolveTypeOfNodeInternal(store, arena, .{
|
||||
.node = rhs.handle.tree.nodes.items(.data)[rhs_node].rhs,
|
||||
|
@ -366,7 +366,6 @@ fn nodeToCompletion(
|
||||
.arena = arena,
|
||||
.orig_handle = orig_handle,
|
||||
};
|
||||
logger.debug("eklafgaef", .{});
|
||||
try analysis.iterateSymbolsContainer(&document_store, arena, node_handle, orig_handle, declToCompletion, context, !is_type_val);
|
||||
}
|
||||
|
||||
@ -623,9 +622,8 @@ fn hoverSymbol(
|
||||
const first_token = param.first_doc_comment orelse
|
||||
param.comptime_noalias orelse
|
||||
param.name_token orelse
|
||||
param.anytype_ellipsis3 orelse
|
||||
tree.firstToken(param.type_expr);
|
||||
const last_token = tree.lastToken(param.type_expr);
|
||||
const last_token = tree.lastToken(param.anytype_ellipsis3 orelse param.type_expr);
|
||||
|
||||
const start = offsets.tokenLocation(tree, first_token).start;
|
||||
const end = offsets.tokenLocation(tree, last_token).end;
|
||||
|
Loading…
Reference in New Issue
Block a user