zig
zig copied to clipboard
std.fmt.parseFloat parses "0x" as 0.0 instead of returning error
Zig Version
0.11.0-dev.1898+36d47dd19
Steps to Reproduce and Observed Behavior
test "parseFloat" {
try std.testing.expectEqual(std.fmt.parseFloat(f64, "0xff"), 255.0);
try std.testing.expectError(std.fmt.ParseFloatError.InvalidCharacter, std.fmt.parseFloat(f64, "0x"));
}
Test [1/1] test.simple test... expected error.InvalidCharacter, found 0.0e+00
Test [1/1] test.simple test... FAIL (TestUnexpectedError)
Expected Behavior
std.fmt.parseFloat(f64, "0x") should return InvalidCharacter, because "0x" is not a valid literal.