lua-users home
lua-l archive

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


On Jan 31, 2018, at 8:40 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

= re.match("aaand", "[a]^2")
.\re.lua: attempt to perform arithmetic on local 'p' (a string value)

the fix is simple, just make sure class range ALWAYS return lpeg object

Thanks for the report.

-- Roberto

BTW, a cleaner fix seems to be this:

-local item = defined + Range + m.C(any)
+local item = defined + Range + m.P(any)

Then, 'item' always results in a pattern.

Sorry...

-local item = defined + Range + m.C(any)
+local item = defined + Range + m.C(any) / m.P

-- Roberto


I think my original patch in the complement functon is safer, and more efficient

We do not need every item to be lpeg object, only its built class
(item were used ONLY to build class range)

one of item choice is defined, which included user defined constants 
that may not be lpeg object. So, the bug is still there.

pat = re.compile("[%star]^10", {star = "*"})
.\re.lua: attempt to perform arithmetic on local 'p' (a string value)