Open davidbrownell opened 9 months ago
We discussed the unexpected behavior of short circuiting conditional expressions in Mojo, such as the expression 0 or "hello"
evaluating to a True
value (of Bool
type). Since Mojo is a statically typed language, it is not trivial to mimic Python’s behavior in this case, since the type of these expressions are not always obvious. In the future, we might be able to do something using existentials: the compiler could find the common traits (or methods) on the types of the two operands and emit something with that conforms to those. For now, we decided that we will not change the existing behavior until we have more dynamic features built out. However, we will document this behavior since it is a potentially confusing deviation from Python.
Thank you for the information, Laszlo!
Bug description
The following code in Mojo prints
True
:In python, the following code prints
hello
:Steps to reproduce
System information