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

Incorrect error inference check on generated types #1386

Closed
tgschultz opened this issue Aug 17, 2018 · 1 comment
Closed

Incorrect error inference check on generated types #1386

tgschultz opened this issue Aug 17, 2018 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@tgschultz
Copy link
Contributor

tgschultz commented Aug 17, 2018

const Struct = struct {
    pub fn func() (error{})!usize {
        return 0;
    }
};

fn AnotherStruct(comptime SubStruct: type) type {
    return struct {
        fn anotherFunc() !void {
            _ = try SubStruct.func();
        }
    };
}

test "incorrect error inference" {
    const GeneratedStruct = AnotherStruct(Struct);
    try GeneratedStruct.anotherFunc();
}
error: function with inferred error set must return at least one possible error
        fn anotherFunc() !void

This can be worked around by declaring the return type of anotherFunc as @typeOf(SubStruct.func).ReturnType.ErrorSet!void

@andrewrk andrewrk added this to the 0.3.0 milestone Aug 17, 2018
@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Aug 17, 2018
@andrewrk
Copy link
Member

I'm going to defer this bug fix as I'm still considering what the behavior should be for cases like these when there is an explicit empty error set or an inferred empty error set.

@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Sep 25, 2018
@andrewrk andrewrk modified the milestones: 0.4.0, 0.5.0 Apr 8, 2019
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Sep 30, 2019
@andrewrk andrewrk added the stage1 The process of building from source via WebAssembly and the C backend. label Feb 10, 2020
@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 Aug 13, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
andrewrk added a commit that referenced this issue Dec 18, 2022
andrewrk added a commit that referenced this issue Dec 18, 2022
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Dec 19, 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 stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

2 participants