From 4d5de1c1fb2decb39d74dfb092ca5643ce47176f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 11 Jul 2018 12:53:23 -0300 Subject: 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. --- testes/errors.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'testes/errors.lua') diff --git a/testes/errors.lua b/testes/errors.lua index 63a7b740..19a7b6fa 100644 --- a/testes/errors.lua +++ b/testes/errors.lua @@ -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() -- cgit v1.2.3-55-g6feb