You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code fails with the following compiler error:
Semantic Analysis [568/862] ./test.zig:4:41: error: expected optional type, found 'f32'
if (std.fmt.parseFloat(f32, string) catch null) |decimal| {
^
./test.zig:11:19: note: called from here
if (comptime f("1")) |x| {
^
./test.zig:10:21: note: called from here
pub fn main() !void {
^
./test.zig:4:5: note: referenced here
if (std.fmt.parseFloat(f32, string) catch null) |decimal| {
^
./test.zig:11:19: note: referenced here
if (comptime f("1")) |x| {
^
/home/philip/Downloads/zig-linux-x86_64-latest/lib/zig/std/start.zig:252:40: note: referenced here
const result = root.main() catch |err| {
Note that removing the comptime part from the call to f in main makes this code compile.
The text was updated successfully, but these errors were encountered:
This is another example of #5401. The result of parseFloat is known at compile time to not be an error so the catch branch is never evaluated. This skips the peer type resolution which would make it an optional type. You can avoid this by explicitly casting the condition @as(?[]const u8, ...).
Vexu
added
the
stage1
The process of building from source via WebAssembly and the C backend.
label
May 29, 2020
This code fails with the following compiler error:
Note that removing the
comptime
part from the call tof
in main makes this code compile.The text was updated successfully, but these errors were encountered: