Skip to content

nested @max intrinsic calls attempt to cast comptime_ints to u6 #15776

@Validark

Description

@Validark

Zig Version

0.11.0-dev.3206+b9d2e0e30

Steps to Reproduce and Observed Behavior

const std = @import("std");

const a = 12;
const b = 32;

pub fn main() void {
    const x = @max(std.math.maxInt(u8), @max(a, b));
    _ = x;
}

output:

src/a.zig:7:35: error: type 'u6' cannot represent integer value '255'
    const x = @max(std.math.maxInt(u8), @max(a, b));
                   ~~~~~~~~~~~~~~~^~~~

Expected Behavior

x should be @as(comptime_int, 255)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions