← All examples

Return in match

A return inside a match arm lands in the function's return type, never in the declaration the match sits in: the 64-bit shift below is a uint64's, not a uint16's.

return_in_match.zg
# A `return` inside a `match` arm lands in the function's return type, never in the declaration the
# match sits in (found by check claude, seed 6868): the 64-bit shift below is a uint64's, not a uint16's.
enum Pick { quick, slow }

fn f [] -> uint64 {
    let 'v': uint16 = match Pick.quick {
        quick { return 8997704354644785536 shr 42; }
        slow { is 1; }
    };
    return to.uint64['v'];
}

MAIN {
    std::print.stored[f[], newln];
}
Output
2045841