lua-users home
lua-l archive

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

There was an off-by-one error in lpeg.Cmt code for lists, I commited a fix and added a test case for the bug.

Fabio Mascarenhas

On Sat, Mar 27, 2010 at 12:45 PM, Wesley Smith <> wrote:
There seems to be a discrepancy with match-time captures in lpeg-list
as compared to lpeg itself.  Switching between strings and lists
creates errors saying "invalid position returned by match-time

local code = "ab"
--local code = {"a", "b"}

local patt = m.L"a" * m.Cmt(
                       function(s, i)
                               return i


I would think that any match-time capture returning the index passed
in to it's second argument (function) would not produce an error, but
when the stream being matched is a list, it causes an error if the
match position is the last element in the  list.  Am I
misunderstanding match-time lists or is this a bug?