We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
0.10.0-dev.3659+e5e6eb983
This may be an intended change, but I didn't see it mentioned in the upgrade guide. This used to compile:
const std = @import("std"); fn bar(s: ?[*:0]const u8) void { _ = s; } fn foo(s: ?[:0]const u8) void { bar(s orelse null); } pub fn main() !void { foo("hello"); }
It compiles.
It doesn't compile:
D:\Scratch\testfn\src\main.zig:8:11: error: expected type '?[*:0]const u8', found '?[:0]const u8' bar(s orelse null); ~~^~~~~~~~~~~ D:\Scratch\testfn\src\main.zig:8:11: note: optional type child '[:0]const u8' cannot cast into optional type child '[*:0]const u8'
The text was updated successfully, but these errors were encountered:
Sorry original code snippet did not actually reproduce the problem, I've updated it with one that does.
Sorry, something went wrong.
this also highlights a current nastyness when using optionals because ideally you could use something like Optional chaining and do s?.ptr
s?.ptr
The type checker is right (I think). Fix: bar(if (s) |ss| ss.ptr else null);
bar(if (s) |ss| ss.ptr else null);
?[:t]T
?[*:t]T
No branches or pull requests
Zig Version
0.10.0-dev.3659+e5e6eb983
Steps to Reproduce
This may be an intended change, but I didn't see it mentioned in the upgrade guide. This used to compile:
Expected Behavior
It compiles.
Actual Behavior
It doesn't compile:
The text was updated successfully, but these errors were encountered: