Skip to content

Proposal: make errdefer in function not returning an error union a compile error #5612

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

Closed
ifreund opened this issue Jun 15, 2020 · 2 comments

Comments

@ifreund
Copy link
Member

ifreund commented Jun 15, 2020

The following compiles despite the errdefer being dead code:

const std = @import("std");

pub fn main() void {
    errdefer std.debug.warn("I'm alive!\n", .{});
    std.debug.warn("hello world!\n", .{});
}

Making this a compile error would avoid dead code hanging around after refactoring.

@ifreund ifreund changed the title Proposal: make errdefer in function not returning error union a compile error Proposal: make errdefer in function not returning an error union a compile error Jun 15, 2020
@Vexu
Copy link
Member

Vexu commented Jun 15, 2020

Duplicate of #2654.

@Vexu Vexu closed this as completed Jun 15, 2020
@ifreund
Copy link
Member Author

ifreund commented Jun 15, 2020

whoops, should've searched first :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants