#Missing anytype inference when migrating to 0.14.0, possible compiler regression?

1 messages · Page 1 of 1 (latest)

muted pendant
#

When migrating a project to Zig 0.14.0-dev, I found that the following code no longer compiles:

const std = @import("std");

pub fn main() !void {
    nice(.{ .b = 42 });
}

const A = union(enum) {
    field: struct {
        b: u32,
    },
};

fn nice(data: anytype) void {
    const a: A = @unionInit(A, "field", data);
    std.debug.print("{}\n", .{a});
}

While this can be easily worked-around, I was wondering if this was a regression or an intended change.

#

Missing anytype inference when migrating to 0.14.0, possible compiler regression?

quartz cove
#

intended change

#

previously anonymous structs without a specific type had a magic unnameable type that allowed shape based coercion like this, that was changed so it has a distinct more normal type now