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

stage2 anyerror + @field() regression #13448

Closed
billzez opened this issue Nov 5, 2022 · 1 comment
Closed

stage2 anyerror + @field() regression #13448

billzez opened this issue Nov 5, 2022 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@billzez
Copy link
Contributor

billzez commented Nov 5, 2022

Zig Version

0.11.0-dev.63+8c4faa5f3

Steps to Reproduce and Observed Behavior

I used to be able to create error unions using @field:

const std = @import("std");

pub fn main() void {
    const e = @field(anyerror, "NotFound");
    std.debug.print("{}\n", .{@TypeOf(e)});
}

This was a handy way of creating error unions at compile time.

But now @TypeOf(e) is always anyerror

Expected Behavior

Stage1 evaluates TypeOf(e) to error{NotFound}

@billzez billzez added the bug Observed behavior contradicts documented or intended behavior label Nov 5, 2022
@billzez
Copy link
Contributor Author

billzez commented Nov 5, 2022

I can use @Type for now, until its removed from the language.

    const E = @Type(std.builtin.Type{
        .ErrorSet = &[_]std.builtin.Type.Error{.{
            .name = "NotFound",
        }},
    });
    var e = @field(E, "NotFound");

#10710

@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Nov 5, 2022
@Vexu Vexu added this to the 0.10.1 milestone Nov 5, 2022
Vexu added a commit to Vexu/zig that referenced this issue Nov 5, 2022
@Vexu Vexu closed this as completed in 5d28d17 Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

2 participants