Skip to content

Compiler fails to build #21850

@joelreymont

Description

@joelreymont

Zig Version

0.14.0-dev.2052+6a364b4a5

Steps to Reproduce and Observed Behavior

Trying to compile this

const std = @import("std");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    const allocator = gpa.allocator();
    const value = toValue(10)(allocator, 20);
    std.debug.print("All your {s} are belong to us.\n", .{value});
}

fn toValue(comptime value: anytype) fn (std.mem.Allocator, anytype) anyerror!@TypeOf(value) {
    return struct {
        fn toValue(_: std.mem.Allocator, _: anytype) !@TypeOf(value) {
            return value;
        }
    }.toValue;
}

gives me this error

❯ zig build
install
└─ install test
   └─ zig build-exe test Debug native failure
error: the following command terminated unexpectedly:
/usr/local/bin/zig build-exe -ODebug -Mroot=/Users/joelr/Work/Zig/test/src/main.zig --cache-dir /Users/joelr/Work/Zig/test/.zig-cache --global-cache-dir /Users/joelr/.cache/zig --name test --zig-lib-dir /usr/local/lib/zig/ --listen=-
Build Summary: 0/3 steps succeeded; 1 failed
install transitive failure
└─ install test transitive failure
   └─ zig build-exe test Debug native failure
error: the following build command failed with exit code 1:
/Users/joelr/Work/Zig/test/.zig-cache/o/4ae0111ced83033f2da7f7f079d783c5/build /usr/local/bin/zig /usr/local/lib/zig /Users/joelr/Work/Zig/test /Users/joelr/Work/Zig/test/.zig-cache /Users/joelr/.cache/zig --seed 0x55c54982 -Z381019e07a3ef546

Expected Behavior

Build should finish.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions