Skip to content

?comptime_int should coerce to optional non-comptime int #4529

@ghost

Description

const T = struct {
    x: bool,
};

pub fn main() void {
    var val: ?usize = @typeInfo(T).Struct.fields[0].offset;
}
./asdf4.zig:6:52: error: expected type '?usize', found '?comptime_int'
    var val: ?usize = @typeInfo(T).Struct.fields[0].offset;
                                                   ^
./asdf4.zig:6:52: note: optional type child 'comptime_int' cannot cast into optional type child 'usize'
    var val: ?usize = @typeInfo(T).Struct.fields[0].offset;
                                                   ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions