Skip to content

coercing enum to union emits broken LLVM module #24174

Open
@EgorkaZ

Description

@EgorkaZ

Zig Version

0.14.1

Steps to Reproduce and Observed Output

run zig init, replace src/main.zig contents with this and run zig build

const std = @import("std");

pub fn main() !void {
    std.debug.print("wont compile {}\n", .{Enum.parse("kekeke")});
}

const Enum = enum {
    a,
    b,

    fn parse(method_str: []const u8) TricksterUnion {
        return std.meta.stringToEnum(Enum, method_str).?;
    }
};

const TricksterUnion = union(Enum) { a, b };

the only error (without any stack trace or anything)

error: Intrinsic has incorrect argument type!
ptr @llvm.memcpy.p0.i1.i64
LLVM ERROR: Broken module found, compilation aborted!

Expected Output

Compiled executable

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend-llvmThe LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions