Zig: broken LLVM module found: Call parameter type does not match function signature!

Created on 27 Sep 2019  路  2Comments  路  Source: ziglang/zig

Not sure if duplicate.
Without the "value" member, there is a compile error on bar = ... (wrong type) as there should be.

With the "value" member, there's an abort.
(zig 0.4.0+805f9b30)

broken LLVM module found: Call parameter type does not match function signature!
  %foo = alloca %Foo, align 4
 { %Foo, i16 }*  call fastcc void @Foo.init(%Foo* sret %foo, %builtin.StackTrace* %0), !dbg !1138

Unable to dump stack trace: debug info stripped
Aborted
const std = @import("std");

const Foo = struct {
    value: u32,

    fn init() anyerror!Foo {
        var mb = Foo{ .value = 42 };
        return mb;
    }
};

const Bar = struct {
    fn init() anyerror!Bar {
        var mb = Bar{};
        return mb;
    }
};

test "With member" {
    var foo: Foo = undefined;
    foo = Foo.init();
}

// test "Without member" {
//     var bar: Bar = undefined;
//     bar = Bar.init();
// }
bug

Most helpful comment

Found this as well. Minimal test case should be this:

fn throws() ![]u8 {
    return error.Failure;
}

const Type = struct {
    pixels: []u8,
};

pub fn main() void
{
    var data = Type {
        .pixels = throws(), // assigning an error union to a field value
    };
}

All 2 comments

Related #3269

Found this as well. Minimal test case should be this:

fn throws() ![]u8 {
    return error.Failure;
}

const Type = struct {
    pixels: []u8,
};

pub fn main() void
{
    var data = Type {
        .pixels = throws(), // assigning an error union to a field value
    };
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

komuw picture komuw  路  3Comments

fengb picture fengb  路  3Comments

zimmi picture zimmi  路  3Comments

jorangreef picture jorangreef  路  3Comments

andrewrk picture andrewrk  路  3Comments