Skip to content

Multi return statement on a single line doesn't cause a compilation error #21787

@eddineimad0

Description

@eddineimad0

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

The following function exhibits the bug.

    pub inline fn bytesPerChannel(self:*const Image)usize{
        return ((return self.chan_bit_depth - 1) >> 3) + 1;
    }

only the inner return statement is evaluated and the outter one is ignored and unreachable, yet zig compiler doesn't throw any errors.

Expected Behavior

The compiler should throw an error upon encountering unreachable return statements same way the following code does

    pub inline fn bytesPerChannel(self:*const Image)usize{
        return ((self.chan_bit_depth - 1) >> 3) + 1;
        return 0;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions