Skip to content
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

Error union on struct field initializer fails silently #9021

Open
pedromsilvapt opened this issue Jun 6, 2021 · 0 comments
Open

Error union on struct field initializer fails silently #9021

pedromsilvapt opened this issue Jun 6, 2021 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@pedromsilvapt
Copy link

On Zig 0.8, if I have a struct field of type Dependency, and I try to assign to it a function that returns !Dependency, the compiler just fails without showing any error message.

Reproduce

const std = @import("std");

pub const Dependency = struct {
    a: i32,

    /// Remove the ! and the code now works
    pub fn init() !Dependency {
        return Dependency{
            .a = 5,
        };
    }
};

pub const Container = struct {
    dependency: Dependency = Dependency.init(),
};

pub fn main() void {
    std.debug.print("Hello world!\n", .{});

    const container = Container{};

    std.debug.print("a = {}\n", .{container.dependency.a});
}
@Vexu Vexu added stage1 The process of building from source via WebAssembly and the C backend. bug Observed behavior contradicts documented or intended behavior labels Jun 7, 2021
@Vexu Vexu added this to the 0.10.0 milestone Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

2 participants