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

@errSetCast refuses to accept an error union operand #17343

Closed
andrewrk opened this issue Oct 1, 2023 · 1 comment · Fixed by #17346
Closed

@errSetCast refuses to accept an error union operand #17343

andrewrk opened this issue Oct 1, 2023 · 1 comment · Fixed by #17346
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Oct 1, 2023

Zig Version

0.12.0-dev.695+303181901

Steps to Reproduce and Observed Behavior

const std = @import("std");

test {
    const bar: error{Bad}!i32 = @errSetCast(foo());
    std.testing.expect((try bar) == 1234);
}

fn foo() anyerror!i32 {
    return 1234;
}
$ stage4/bin/zig test test.zig 
test.zig:4:33: error: expected error set type, found 'i32'
    const bar: error{Bad}!i32 = @errSetCast(foo());
                                ^~~~~~~~~~~~~~~~~~

Expected Behavior

Test passed.

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Oct 1, 2023
@andrewrk andrewrk added this to the 0.12.0 milestone Oct 1, 2023
andrewrk added a commit that referenced this issue Oct 1, 2023
The idea here is to avoid code bloat by having only one actual io.Reader
implementation, which is type erased, and then implement a GenericReader
that preserves type information on top of that as thin glue code.

The strategy here is for that glue code to `@errSetCast` the result of
the type-erased reader functions, however, while trying to do that I
ran into #17343.
Vexu added a commit to Vexu/zig that referenced this issue Oct 1, 2023
andrewrk added a commit that referenced this issue Oct 1, 2023
The idea here is to avoid code bloat by having only one actual io.Reader
implementation, which is type erased, and then implement a GenericReader
that preserves type information on top of that as thin glue code.

The strategy here is for that glue code to `@errSetCast` the result of
the type-erased reader functions, however, while trying to do that I
ran into #17343.
andrewrk added a commit that referenced this issue Oct 3, 2023
The idea here is to avoid code bloat by having only one actual io.Reader
implementation, which is type erased, and then implement a GenericReader
that preserves type information on top of that as thin glue code.

The strategy here is for that glue code to `@errSetCast` the result of
the type-erased reader functions, however, while trying to do that I
ran into #17343.
andrewrk added a commit that referenced this issue Oct 3, 2023
The idea here is to avoid code bloat by having only one actual io.Reader
implementation, which is type erased, and then implement a GenericReader
that preserves type information on top of that as thin glue code.

The strategy here is for that glue code to `@errSetCast` the result of
the type-erased reader functions, however, while trying to do that I
ran into #17343.
andrewrk added a commit that referenced this issue Oct 3, 2023
The idea here is to avoid code bloat by having only one actual io.Reader
implementation, which is type erased, and then implement a GenericReader
that preserves type information on top of that as thin glue code.

The strategy here is for that glue code to `@errSetCast` the result of
the type-erased reader functions, however, while trying to do that I
ran into #17343.
krichprollsch added a commit to lightpanda-io/zig-js-runtime that referenced this issue Dec 4, 2023
krichprollsch added a commit to lightpanda-io/browser that referenced this issue Dec 4, 2023
krichprollsch added a commit to lightpanda-io/browser that referenced this issue Dec 4, 2023
krichprollsch added a commit to lightpanda-io/zig-js-runtime that referenced this issue Dec 4, 2023
krichprollsch added a commit to lightpanda-io/browser that referenced this issue Dec 4, 2023
krichprollsch added a commit to lightpanda-io/browser that referenced this issue Dec 5, 2023
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

Successfully merging a pull request may close this issue.

1 participant