Skip to content

Conversation

@jethron
Copy link
Contributor

@jethron jethron commented May 24, 2020

Fixes #4582

Produces zig target output like:
"triple": "x86_64-freebsd.13.0.95...13.0.95-gnu",

Catch unreachable because:
error.PermissionDenied: Only happens when setting values
error.SystemResources: Memory is already allocated on the stack
error.NameTooLong: Known good value
error.UnknownName: Known good value
error.Unexpected: The pointers are to stack values (EFAULT), and the sysctl name is known good (ENOTDIR, EISDIR)

@andrewrk
Copy link
Member

Catch unreachable because:

I appreciate the explanation of each reason the error is not possible - can you move this valuable information into the code?

catch |err| switch (err) {
    error.PermissionDenied => unreachable, // Only happens when setting values
...
}

What's really nice about this is that if a line does happen to get reached, the stack trace will show what happened along with the comment explaining why it wasn't supposed to happen!

This will also cause the compiler to detect if that function ever gained or lost error set values.

@jethron
Copy link
Contributor Author

jethron commented May 24, 2020

Thanks @andrewrk, makes sense, done

@andrewrk andrewrk merged commit 4b1a846 into ziglang:master May 25, 2020
@andrewrk
Copy link
Member

Thanks @jethron!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

os-freebsd FreeBSD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

implement the native operating system version detection for FreeBSD

3 participants