Second param for 'error' call do not change actual source/line in error message #60

Closed
opened 2019-10-20 15:31:36 +00:00 by Enyby · 0 comments
Enyby commented 2019-10-20 15:31:36 +00:00 (Migrated from github.com)

Test code:

local function lineerror (s, l)
  local err,msg = pcall(load(s))
  local line = string.match(msg, ":(%d+)[:\n ]")
  print(line, l)
  assert((line and line+0) == l, 'line = '..tostring(line)..'; l = '..tostring(l)..'; msg = "'..tostring(msg)..'"')
end

local p = [[
  function g() f() end
  function f(x) error('a', X) end
g()
]]
X=3;lineerror((p), 3)
X=0;lineerror((p), nil)
X=1;lineerror((p), 2)
X=2;lineerror((p), 1)
Test code: ``` local function lineerror (s, l) local err,msg = pcall(load(s)) local line = string.match(msg, ":(%d+)[:\n ]") print(line, l) assert((line and line+0) == l, 'line = '..tostring(line)..'; l = '..tostring(l)..'; msg = "'..tostring(msg)..'"') end local p = [[ function g() f() end function f(x) error('a', X) end g() ]] X=3;lineerror((p), 3) X=0;lineerror((p), nil) X=1;lineerror((p), 2) X=2;lineerror((p), 1) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: open-autonomous-connection/luaj#60