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

tagged union with only one field trips assertion #1495

Closed
andrewrk opened this Issue Sep 10, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@andrewrk
Member

andrewrk commented Sep 10, 2018

example provided by @cgag

const std  = @import("std");
const warn = std.debug.warn;
const fmt  = std.fmt;
const mem  = std.mem;

var alloc = &std.heap.DirectAllocator.init().allocator;

pub const Expr = union(enum) {
    Literal: Literal,
};

pub const Literal = union(enum) {
    Number: f64,
    Bool: bool,
};

pub fn main() !void {
    const s = try fmt.allocPrint(alloc, "{}", Expr{.Literal=Literal{.Bool=true}});
    warn("{}\n",s);
}
zig: /home/andy/downloads/zig/src/codegen.cpp:4721: LLVMOpaqueValue* ir_render_union_tag(CodeGen*, IrExecutable*, IrInstructionUnionTag*): Assertion `union_type->data.unionation.gen_tag_index != SIZE_MAX' failed.

@andrewrk andrewrk added the bug label Sep 10, 2018

@andrewrk andrewrk added this to the 0.3.0 milestone Sep 10, 2018

@andrewrk andrewrk closed this in 22e39e1 Sep 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment