Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Shifted literal into `fmt.printf` (into `any`?) does not compile

Open jasonKercher opened this issue 11 months ago • 1 comments

Context

  • Operating System & Odin Version:
        Odin:    dev-2024-11:7cfaf0b18
        OS:      Windows 10 Professional (version: 21H2), build 19044.2846
        CPU:     Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
        RAM:     16275 MiB
        Backend: LLVM 18.1.8

(reproduced on Linux)

Expected Behavior

This should compile:

package main
import "core:fmt"
main :: proc()
{
        for i : uint = 0; i < 16; i += 1 {
                fmt.printf("%u %u\n", i, 4096 << i)
        }
}

Current Behavior

/home/jason/dev/shnt/a.odin(8:28) Error: Conversion of shifted operand '4096' to 'bool' is not allowed
        fmt.printf("%u %u\n", i, 4096 << i)
                                 ^~~~~~~~^

Failure Information (for bugs)

This does work, so it seems to be a problem with sending the literal.

package main
import "core:fmt"
main :: proc()
{
        for i : uint = 0; i < 16; i += 1 {
                shifted := 4096 << i
                fmt.printf("%u %u %08x\n", i, shifted, shifted)
        }
}

jasonKercher avatar Nov 02 '24 20:11 jasonKercher