odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.56k stars 570 forks source link

Cannot cast untyped bool to integer #3981

Open GoldenbergDaniel opened 1 month ago

GoldenbergDaniel commented 1 month ago

Context

Odin: dev-2024-07:b4ca044ae OS: macOS Sonoma 14 (build: 23A344, kernel: 23.0.0) CPU: Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz RAM: 8192 MiB Backend: LLVM 18.1.7

Expected Behavior

Should be able to cast an untyped boolean expression to an integer.

Current Behavior

  1. int(2 < 1) == 0 // Error: Cannot cast '2 < 1' as 'int' from 'untyped bool'
  2. int(true) == 0 // Error: Cannot cast 'true' as 'int' from 'untyped bool'
  3. int(my_bool) == 0 // Success
laytan commented 1 month ago

@gingerBill seems to have explicitly disabled this in 3fc60930 , assigning to him for clarity