capy-language / capy

🍊 A statically typed, compiled programming language, largely inspired by Jai, Odin, and Zig.
Apache License 2.0
64 stars 4 forks source link

failed autocast #41

Open lenawanel opened 3 months ago

lenawanel commented 3 months ago

Problem

the function

log2_u64 :: (n: u64) -> u64 {
    n := n;
    i := 0;
    while n != 0 {
        n = n << 1;
        i = i + 1;
    }
    i
}

will panic, saying that there is a mismatch between the operand types of an iadd. manually casting the last 1 into a u64 removes the panic.

log2_u64 :: (n: u64) -> u64 {
    n := n;
    i := 0;
    while n != 0 {
        n = n << 1;
        i = i + 1 as u64;
    }
    i
}

Steps

No response

Notes

No response

Does this happen on the latest commit?

Yes

What targets are you seeing the problem on?

windows