lua-users home
lua-l archive

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


This whole story goes back to these messages:

  https://github.com/xolox/lua-lxsh/issues/5             (the problem)
  http://lua-users.org/lists/lua-l/2015-07/msg00356.html   (the "fix")

The issue is that I "fixed" the wrong problem, because of a bad
error message. The original problem was the one that appeared in the
OP:

> lpeg = require"lpeg"
> D = lpeg.R'09'
> BB = lpeg.B(-D, 1)
stdin:1: bad argument #1 to 'B' (pattern may not have fixed length)

But of course 'B' has a fixed length, and so the "obvious fix" for that
message was to allow fixed lengths equal to zero. But look behind with
zero lengths may be correct from a formal point of view, but they are
useless (as it means "go back zero positions") and probably not doing
what the programmer expects. The correct fix should be to rephrase the
error message, not to allow look behind with zero-length patterns.

-- Roberto