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

better handling of error set integer type #786

Open
andrewrk opened this issue Feb 24, 2018 · 0 comments
Open

better handling of error set integer type #786

andrewrk opened this issue Feb 24, 2018 · 0 comments
Milestone

Comments

@andrewrk
Copy link
Member

@andrewrk andrewrk commented Feb 24, 2018

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.

@andrewrk andrewrk added the proposal label Feb 24, 2018
@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Feb 24, 2018
@andrewrk andrewrk added the accepted label Nov 21, 2018
@andrewrk andrewrk modified the milestones: 0.4.0, 0.5.0 Mar 22, 2019
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Sep 2, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Feb 10, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant