Fixed bug in line info. when using 'not' operator

When creating code for a jump on a 'not' condition, the code generator
was removing an instruction (the OP_NOT) without adjusting its
corresponding line information.

This fix also added tests for this case and extra functionality in
the test library to debug line info. structures.
This commit is contained in:
Roberto Ierusalimschy
2018-07-11 12:53:23 -03:00
parent 9a825f6bb9
commit 4d5de1c1fb
3 changed files with 93 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
-- $Id: errors.lua,v 1.97 2017/11/28 15:31:56 roberto Exp $
-- $Id: errors.lua $
-- See Copyright Notice in file all.lua
print("testing errors")
@@ -299,7 +299,7 @@ end
local function lineerror (s, l)
local err,msg = pcall(load(s))
local line = string.match(msg, ":(%d+):")
assert((line and line+0) == l)
assert(tonumber(line) == l)
end
lineerror("local a\n for i=1,'a' do \n print(i) \n end", 2)
@@ -350,6 +350,23 @@ X=1;lineerror((p), 2)
X=2;lineerror((p), 1)
lineerror([[
local b = false
if not b then
error 'test'
end]], 3)
lineerror([[
local b = false
if not b then
if not b then
if not b then
error 'test'
end
end
end]], 5)
if not _soft then
-- several tests that exaust the Lua stack
collectgarbage()