Here is some code:
pub fn convertAnimationSet(spec: specs.AnimationSetSpec, sheet: core.graphics.Sheet, allocator: std.mem.Allocator)
struct { skeleton: core.animation.Skeleton, skin: core.animation.Skin } {
// ... stuff here, create "result" and "skin" variables for later
// the next line is where I get an error
const animBuilder = try core.animation.AnimationBuilder.init(std.heap.page_allocator, 10);
_ = animBuilder;
return .{ .skeleton = result, .skin = skin };
}
Here’s the error I’m getting:
src/game/animation.zig:117:25: error: expected type 'animation.convertAnimationSet__struct_34611', found '@typeInfo(@typeInfo(@TypeOf(animation.animationBuilder.AnimationBuilder.init)).Fn.return_type.?).ErrorUnion.error_set'
const animBuilder = try core.animation.AnimationBuilder.init(std.heap.page_allocator, 10);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/game/animation.zig:7:5: note: struct declared here
struct { skeleton: core.animation.Skeleton, skin: core.animation.Skin } {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/game/animation.zig:7:5: note: function cannot return an error
struct { skeleton: core.animation.Skeleton, skin: core.animation.Skin } {
I really don’t understand why it’s complaining about the call to core.animation.AnimationBuilder.init()
. It seems like the compiler thinks I’m trying to return the result of core.animation.AnimationBuilder.init()
directly from this function, which is wrong.
Am I doing something wrong, or is this a compiler bug? I’m using Zig 0.12.0-dev.2063+804cee3b9.