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.zon writes invalid negative zero #23343

Closed
alichraghi opened this issue Mar 24, 2025 · 1 comment · Fixed by #23345
Closed

std.zon writes invalid negative zero #23343

alichraghi opened this issue Mar 24, 2025 · 1 comment · Fixed by #23345
Labels
bug Observed behavior contradicts documented or intended behavior standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@alichraghi
Copy link
Contributor

alichraghi commented Mar 24, 2025

Zig Version

0.15.0-dev.64+2a4e06bcb

Steps to Reproduce and Observed Behavior

const std = @import("std");

test {
    const value: struct { x: f32 } = .{ .x = -0.0 };
    try std.zon.stringify.serialize(value, .{}, std.io.getStdOut().writer());
    // Prints .{ .x = -0 }
}

Expected Behavior

Should've produced .{ .x = -0.0 } since -0 is a negative zero int literal which is invalid

@alichraghi alichraghi added the bug Observed behavior contradicts documented or intended behavior label Mar 24, 2025
@alichraghi alichraghi changed the title std.zon doesn't normalize negative zeroes std.zon writes invalid negative zero Mar 24, 2025
@mlugg mlugg added the standard library This issue involves writing Zig code for the standard library. label Mar 24, 2025
@mlugg mlugg added this to the 0.14.1 milestone Mar 24, 2025
@mlugg
Copy link
Member

mlugg commented Mar 24, 2025

cc @MasonRemaley

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 standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants