[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Bug with logical operator or misunderstanding?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 27 Jan 2011 11:50:29 -0200
> Hmm, we're not there yet. Your patch 5.1.4 yields the correct results
> for these two cases:
> assert((((1 or false) and true) or false) == true)
> assert((((1 or 2) and true) or false) == true)
> but it doesn't fix these cases:
> assert(((nil and true) or false and true) == false)
> assert((((nil and true) or false) and true) == false)
It seems that there are several other cases with wrong results,
including cases where even the truthness of the expression is wrong:
$ lua -e 'print((10 or false) and (false and nil))'
10 (should be false)
$ lua -e 'print((nil and nil) or (true or 10))'
nil (should be true)
What is awful is that this bug is present since version 5.0 and
we haven't found it till now. (Well, nobody writes code like that,
but it may appear in machine-generated coee.)
The attached program tests all cases with up to 3 connectives (and/or)
and prints the buggy ones. (It assumes that the basic and/or is
working :) The patch that removes all optimizations seems to correct
Description: GENbank data