lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I don't know how I missed that. Yes, that's exactly the same issue.

Thanks,

Thierry


-----Message d'origine-----
De : lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] De la part de Michal Kottman
Envoyé : 20 janvier 2011 10:46
À : Lua mailing list
Objet : Re: Bug with logical operator or misunderstanding?

On Thu, 2011-01-20 at 10:37 -0500, Thierry Van Elsuwe wrote:
> local OneOrTwo = (1 or 2)
> local a = (OneOrTwo) and true or false
> local b = (1 or 2) and true or false
> local True = true
> local c = (1 or 2) and True or false

> print(a)
> print(b)
> print(c)

> The result is :

> true
> 1
> true

> I was expecting to get the following result:

> true
> true
> true
> 
> Is this a bug, or can someone can explain me why we have 1 instead of
> true?

I guess this is a known bug - http://www.lua.org/bugs.html#5.1.4-3 .