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

indexing a string has unknown type #1973

Open
doongjohn opened this issue Jul 23, 2024 · 0 comments
Open

indexing a string has unknown type #1973

doongjohn opened this issue Jul 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@doongjohn
Copy link

doongjohn commented Jul 23, 2024

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 doongjohn added the bug Something isn't working label Jul 23, 2024
@doongjohn doongjohn changed the title capturing u8 from a string in a for loop has unknown type indexing a string has unknown type Jul 24, 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