-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Setting optionals to undefined defaults to null in debug mode #8333
Labels
Milestone
Comments
This happens with error unions too, just had a confusing debugging session because of it. test {
var a: anyerror!u32 = undefined;
_ = a catch unreachable;
} |
RetroDev256
added a commit
to RetroDev256/zig
that referenced
this issue
Sep 9, 2024
RetroDev256
added a commit
to RetroDev256/zig
that referenced
this issue
Sep 9, 2024
RetroDev256
added a commit
to RetroDev256/zig
that referenced
this issue
Sep 9, 2024
RetroDev256
added a commit
to RetroDev256/zig
that referenced
this issue
Sep 9, 2024
RetroDev256
added a commit
to RetroDev256/zig
that referenced
this issue
Sep 9, 2024
RetroDev256
added a commit
to RetroDev256/zig
that referenced
this issue
Sep 10, 2024
RetroDev256
added a commit
to RetroDev256/zig
that referenced
this issue
Sep 10, 2024
RetroDev256
added a commit
to RetroDev256/zig
that referenced
this issue
Nov 24, 2024
alexrp
pushed a commit
to RetroDev256/zig
that referenced
this issue
Feb 5, 2025
RetroDev256
added a commit
to RetroDev256/zig
that referenced
this issue
Feb 5, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If we do a simple undefined optional (
var foo: ?u32 = undefined;
), this gets converted to null only in debug mode: https://zig.godbolt.org/z/5a6ca8bz8. This is correctly set to 0xAAAA in release-safe.This feels like a footgun as simple testing will trigger wrong assumptions.
The text was updated successfully, but these errors were encountered: