Logical and/or do not short-circuit
-
a = foo() and bar() sleep(2) function foo() print("foo") return false function bar() print("bar") return falseI expected this little program to print "foo", but it actually prints "barfoo".
Looks like 'and' evaluates its operands right to left and does not short-circuit evaluation when the first operand evaluates to false. I don't know if this is a bug but it's a bit different from how logical operations usually work in other languages. -
@sahara-min I once ran into a bug in my game, and it was due to me assuming operators short-circuit, which they weren't. I re-wrote the single if statement into a nested one, and my bug went away.
So I think you're on to something here :D