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

std.debug.print("{}\n", .{1e.5}); should not compile #20385

Open
germay opened this issue Jun 22, 2024 · 1 comment · May be fixed by #20400
Open

std.debug.print("{}\n", .{1e.5}); should not compile #20385

germay opened this issue Jun 22, 2024 · 1 comment · May be fixed by #20400
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@germay
Copy link

germay commented Jun 22, 2024

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

std.debug.print("{}\n", .{1e.5}); => 0e0

Expected Behavior

Code should not compile.

1e.5 is not a vaild floating point literal.

Trying this in c gives error: exponent has no digits

@germay germay added the bug Observed behavior contradicts documented or intended behavior label Jun 22, 2024
@Vexu
Copy link
Member

Vexu commented Jun 22, 2024

thread 49223 panic: attempt to unwrap error: InvalidCharacter
/home/vexu/Documents/zig/zig/lib/std/fmt/parse_float.zig:42:9: 0xb174ae6 in parseFloat__anon_101863 (zig)zig
        return parse.parseInfOrNan(T, s[i..], negative) orelse error.InvalidCharacter;
        ^
/home/vexu/Documents/zig/zig/lib/std/zig/AstGen.zig:8576:43: 0xac80d59 in numberLiteral (zig)
                error.InvalidCharacter => unreachable, // validated by tokenizer
                                          ^
/home/vexu/Documents/zig/zig/lib/std/zig/AstGen.zig:804:48: 0xa791f63 in expr (zig)
        .number_literal => return numberLiteral(gz, ri, node, node, .positive),
                                               ^

@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Jun 22, 2024
@Vexu Vexu added this to the 0.14.0 milestone Jun 22, 2024
@wooster0 wooster0 linked a pull request Jun 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants