zls icon indicating copy to clipboard operation
zls copied to clipboard

indexing a string has unknown type

Open doongjohn opened this issue 1 year ago • 0 comments

Zig Version

0.14.0-dev.367+a57479afc

Zig Language Server Version

0.14.0-dev.54+adf3b83

Client / Code Editor / Extensions

nvim 0.10.0 with nvim-lspconfig

Steps to Reproduce and Observed Behavior

const s = "hello";
const b = s[0];
_ = b;

^ b has unknown type.

image Explicitly specifying the string type fixes the issue.

pub fn main() void {
    const string = "Hello, world!";
    for (string) |byte| {
        _ = byte;
    }

    for ("hello") |byte| {
        _ = byte;
    }
}

image image

Expected Behavior

Type of the indexed value should be u8.

Relevant log output

No response

doongjohn avatar Jul 23 '24 21:07 doongjohn