Skip to content

allow configuration of error set tag type via a public const in the root source file #786

@andrewrk

Description

@andrewrk

Right now error sets are hardcoded to codegen to a u16.

Ideally, zig would choose an appropriate sized integer based on the total number of error values in the compilation, but the user may do @sizeOf(SomeStruct) which has an error set type as a field before the entire compilation finishes analysis. This would create a circular dependency.

One idea is to have the error set integer type have a default of u32, but in the same way that you can override the default panic handler in the root source file, you can override the error set integer type in the root source file by doing:

pub const ErrorIntegerType = u8;

Then you'd get a compile error if zig ran out of bits when choosing error values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions