Skip to content

Sema: incompatible types with @min which is supposed to accept arbitrary integer types #23139

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
jacobly0 opened this issue Mar 8, 2025 · 1 comment · Fixed by #23914
Closed
Labels
bug Observed behavior contradicts documented or intended behavior error message This issue points out an error message that is unhelpful and should be improved. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@jacobly0
Copy link
Member

jacobly0 commented Mar 8, 2025

fn min(lhs: i32, rhs: u32) i32 {
    return @min(lhs, rhs);
}
comptime {
    _ = &min;
}
$ zig build-obj repro.zig
repro.zig:2:12: error: incompatible types: 'i32' and 'u32'
    return @min(lhs, rhs);
           ^~~~~~~~~~~~~~
repro.zig:2:17: note: type 'i32' here
    return @min(lhs, rhs);
                ^~~
repro.zig:2:22: note: type 'u32' here
    return @min(lhs, rhs);
                     ^~~
@jacobly0 jacobly0 added bug Observed behavior contradicts documented or intended behavior error message This issue points out an error message that is unhelpful and should be improved. frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Mar 8, 2025
@jacobly0 jacobly0 added this to the 0.15.0 milestone Mar 8, 2025
@flyfish30
Copy link
Contributor

@jacobly0 I had resolved this issue, can you review my PR.

mlugg added a commit to mlugg/zig that referenced this issue May 17, 2025
I only wanted to fix a bug originally, but this logic was kind of a
rat's nest. But now... okay, it still *is*, but it's now a slightly more
navigable nest, with cute little signs occasionally, painted by adorable
rats desparately trying to follow the specification.

Hopefully ziglang#3806 comes along at some point to simplify this logic a
little.

Resolves: ziglang#23139
mlugg added a commit to mlugg/zig that referenced this issue May 18, 2025
I only wanted to fix a bug originally, but this logic was kind of a
rat's nest. But now... okay, it still *is*, but it's now a slightly more
navigable nest, with cute little signs occasionally, painted by adorable
rats desparately trying to follow the specification.

Hopefully ziglang#3806 comes along at some point to simplify this logic a
little.

Resolves: ziglang#23139
mlugg added a commit that referenced this issue May 18, 2025
I only wanted to fix a bug originally, but this logic was kind of a
rat's nest. But now... okay, it still *is*, but it's now a slightly more
navigable nest, with cute little signs occasionally, painted by adorable
rats desparately trying to follow the specification.

Hopefully #3806 comes along at some point to simplify this logic a
little.

Resolves: #23139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior error message This issue points out an error message that is unhelpful and should be improved. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
2 participants