Why compiler did not detect leak

For more context, please refer to these threads:

Also, you may want to consider looking at functions in the standard library:

std.ascii.toLower
/// Lowercases the character and returns it as-is if already lowercase or not a letter.
pub fn toLower(c: u8) u8 {
    const mask = @as(u8, @intFromBool(isUpper(c))) << 5;
    return c | mask;
}
3 Likes