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

Test "naughty pointer" does not compile #275

Open
ghost opened this issue Oct 13, 2024 · 0 comments · May be fixed by #281
Open

Test "naughty pointer" does not compile #275

ghost opened this issue Oct 13, 2024 · 0 comments · May be fixed by #281

Comments

@ghost
Copy link

ghost commented Oct 13, 2024

I tried the "naughty pointer" test from Language / Pointers and it didn't compile (with Zig 0.13.0):

test "naughty pointer" {
    var x: u16 = 0;
    var y: *u8 = @ptrFromInt(x);
    _ = y;
}

For both variables it said error: local variable is never mutated and note: consider using 'const'.

So I guess instead it should now be:

test "naughty pointer" {
    const x: u16 = 0;
    const y: *u8 = @ptrFromInt(x);
    _ = y;
}

I would have opened a pull request, but I think the output of the test also needs updating (because now it's a different, cleaner message), and my test files wouldn't match yours so it wouldn't look good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

0 participants