zls
zls copied to clipboard
No inlay hints for struct_init* fields following a `return` and the fn's return type is an optional
Zig Version
Zig Language Server Version
dfe958e
Client / Code Editor / Extensions
Steps to Reproduce and Observed Behavior
Can be observed for any fn f() ?T in the codebase that return .{.x ..,
but not for fn that have an explicit error(set), ie fn f() error{E}!?T works.
const T = union(enum) { a: u1 };
fn foo() ?T {
return .{ .a = 1 };
}
Same even if the type is explicitly specified,
const T = union(enum) { a: u1 };
fn foo() ?T {
return T{ .a = 1 };
}
Cause: https://github.com/zigtools/zls/blob/dfe958e4d1a9ba503cfafd39164f090daea70109/src/analysis.zig#L4494-L4498
resolveOptionalUnwrap doesn't do type_vals
E!?T works because resolveUnwrapErrorUnionType returns an 'instance' of ?T
Expected Behavior
Relevant log output
No response