librelist archives

« back to archive

bug of set union operation in LGLIB

bug of set union operation in LGLIB

From:
Lu Wenlong
Date:
2011-12-19 @ 03:33
there is a bug:

set1 = Set {1, 2, 3}
set2 = Set {"a", "b", "c"}

after you call *ptable(set1 + set2)*
the empty set will come out.

After tracing the steps, I found that the bug rooted in the following lines:
set.lua:60-65*  return Set(table.merge(self, set, true)) *
Set.lua:20-30  for _, v in *ipairs*(tbl) do  xxxxx end
the requirement of initialization of Set is that the arg should be
LIST/ARRAY-style. Here it can not be guaranteed after calling table.merge().


Wenlong
-- 
沒有理想走不遠,不面對現實連今天都走不過.

Re: bug of set union operation in LGLIB

From:
Lu Wenlong
Date:
2011-12-19 @ 03:38
it can be solved by throwing away the initialization process
*return Set(table.merge(self, set, true)) ----->**return table.merge(self,
set, true) *

2011/12/19 Lu Wenlong <a88i99@gmail.com>

> there is a bug:
>
> set1 = Set {1, 2, 3}
> set2 = Set {"a", "b", "c"}
>
> after you call *ptable(set1 + set2)*
> the empty set will come out.
>
> After tracing the steps, I found that the bug rooted in the following
> lines:
> set.lua:60-65*  return Set(table.merge(self, set, true)) *
> Set.lua:20-30  for _, v in *ipairs*(tbl) do  xxxxx end
> the requirement of initialization of Set is that the arg should be
> LIST/ARRAY-style. Here it can not be guaranteed after calling table.merge().
>
>
> Wenlong
> --
> 沒有理想走不遠,不面對現實連今天都走不過.
>
>
>
>


-- 
沒有理想走不遠,不面對現實連今天都走不過.

Re: [bamboo] Re: bug of set union operation in LGLIB

From:
Tang Daogang
Date:
2011-12-19 @ 05:16
fixed.

On Mon, Dec 19, 2011 at 11:38 AM, Lu Wenlong <a88i99@gmail.com> wrote:

> it can be solved by throwing away the initialization process
> *return Set(table.merge(self, set, true)) ----->**return
> table.merge(self, set, true) *
>
> 2011/12/19 Lu Wenlong <a88i99@gmail.com>
>
>> there is a bug:
>>
>> set1 = Set {1, 2, 3}
>> set2 = Set {"a", "b", "c"}
>>
>> after you call *ptable(set1 + set2)*
>> the empty set will come out.
>>
>> After tracing the steps, I found that the bug rooted in the following
>> lines:
>> set.lua:60-65*  return Set(table.merge(self, set, true)) *
>> Set.lua:20-30  for _, v in *ipairs*(tbl) do  xxxxx end
>> the requirement of initialization of Set is that the arg should be
>> LIST/ARRAY-style. Here it can not be guaranteed after calling table.merge().
>>
>>
>> Wenlong
>> --
>> 沒有理想走不遠,不面對現實連今天都走不過.
>>
>>
>>
>>
>
>
> --
> 沒有理想走不遠,不面對現實連今天都走不過.
>
>
>
>


-- 
Nothing is impossible.