lua-users home
lua-l archive

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


On 20 July 2015 at 18:07, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2015-07-19 23:40 GMT+02:00 Parke <parke.nexus@gmail.com>:
>
>> If a named group capture has a name that is a number (as opposed to a
>> string), then when that named group is captured inside a table
>> capture, the key used to store the value will be the number converted
>> to a string (rather than the number itself).
>
> The second parameter to Cg is retrieved using luaL_checkstring.
> This function does number-to-string coercion.
>
> The key is called a "name" in the documentation, which gives
> a light hint that its type is expected to be string.
>

Reading through the code I can't seem to seem to see any reason for
that checkstring call to be there.
Removing it, all tests still pass, and this works:

local lpeg = require "lpeg"
local t = {}
local p = lpeg.Ct(lpeg.Cg(lpeg.P("foo"), t))
local r = p:match("foo")
assert(next(r) == t)

Roberto, you said you were making a new lpeg release soon; perhaps you
can remove this un-required luaL_checkstring?