Skip to content

anytype fields cannot be initiated to array or struct literals #5877

Closed
@Vexu

Description

@Vexu
const S = struct {
    foo: anytype,
};
comptime {
    var s = S{
        // error: array access of non-array type '(anytype)'
        .foo = [2]u8{0,1},
    };
    // this works
    // var s = S{
    //     .foo = 1,
    // };
    // var b = [2]u8{ 0, 1 };
    // s.foo = b;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions