Skip to content

std.zon writes invalid negative zero #23343

Closed
@alichraghi

Description

@alichraghi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions