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

inferred error sets have strippable identity (missing documentation?) #20862

Open
rohlem opened this issue Jul 29, 2024 · 1 comment
Open

inferred error sets have strippable identity (missing documentation?) #20862

rohlem opened this issue Jul 29, 2024 · 1 comment
Labels
Milestone

Comments

@rohlem
Copy link
Contributor

rohlem commented Jul 29, 2024

Zig Version

0.14.0-dev.617+208baa37c

Steps to Reproduce and Observed Behavior

Repro:

fn foo() !void {}
comptime {
    const A = @typeInfo(@TypeOf(foo())).ErrorUnion.error_set;
    const B = error{};
    @compileLog(A == B); //false
    @compileLog((A || error{}) == B); //true
    @compileLog(@Type(@typeInfo(A)) == B); //true
}

Expected Behavior

I didn't know that inferred error sets have identity that makes them compare unequal to all other error sets - it's not currently mentioned in their langref section.

When looking for previous issues on this I found that all error sets used to have identity, which changed with implementing #11022 .
A comment there documents that "we're experimenting" with inferred error sets having identity "to ease the implementation of the language specification. It's problematic to make type equality force error set resolution."
If that's still the current stance on the issue, I can accept that it just needs to be documented.

@rohlem rohlem added the bug Observed behavior contradicts documented or intended behavior label Jul 29, 2024
@mlugg
Copy link
Member

mlugg commented Jul 29, 2024

Yep, status quo is intended, and this is just missing documentation.

@mlugg mlugg added docs and removed bug Observed behavior contradicts documented or intended behavior labels Jul 29, 2024
@mlugg mlugg added this to the 1.0.0 milestone Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants