Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zls shows wrong variable type hint when RHS expression has function returning optional and orelse is used to return error set #1728

Open
eshom opened this issue Jan 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@eshom
Copy link

eshom commented Jan 26, 2024

Zig Version

0.12.0-dev.2341+92211135f

Zig Language Server Version

0.12.0-dev.365+a8a83b6

Client / Code Editor / Extensions

emacs 29.1 (eglot)

Steps to Reproduce and Observed Behavior

With variable type hints enabled (should be the default) paste to your editor:

const std = @import("std");

fn myNull() ?i32 {
    return null;
}

pub fn main() !void {
    const y = myNull();
    const x = myNull() orelse error.NullValue;
    std.debug.print("My value: {d}\n", .{try x});
    _ = y;
}

In my editor notice that type hint for x is i32:
image

Expected Behavior

Expected type hint for x is error{NullValue}!i32

Relevant log output

No response

@eshom eshom added the bug Something isn't working label Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant