aboutsummaryrefslogtreecommitdiff
path: root/testes/errors.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-07-11 12:53:23 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-07-11 12:53:23 -0300
commit4d5de1c1fb2decb39d74dfb092ca5643ce47176f (patch)
tree6d211899db43994b5d421a8a7e59dcb2ecccc0db /testes/errors.lua
parent9a825f6bb9a141023ac519a73f6a9958c113659e (diff)
downloadlua-4d5de1c1fb2decb39d74dfb092ca5643ce47176f.tar.gz
lua-4d5de1c1fb2decb39d74dfb092ca5643ce47176f.tar.bz2
lua-4d5de1c1fb2decb39d74dfb092ca5643ce47176f.zip
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.
Diffstat (limited to 'testes/errors.lua')
-rw-r--r--testes/errors.lua21
1 files changed, 19 insertions, 2 deletions
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 @@
1-- $Id: errors.lua,v 1.97 2017/11/28 15:31:56 roberto Exp $ 1-- $Id: errors.lua $
2-- See Copyright Notice in file all.lua 2-- See Copyright Notice in file all.lua
3 3
4print("testing errors") 4print("testing errors")
@@ -299,7 +299,7 @@ end
299local function lineerror (s, l) 299local function lineerror (s, l)
300 local err,msg = pcall(load(s)) 300 local err,msg = pcall(load(s))
301 local line = string.match(msg, ":(%d+):") 301 local line = string.match(msg, ":(%d+):")
302 assert((line and line+0) == l) 302 assert(tonumber(line) == l)
303end 303end
304 304
305lineerror("local a\n for i=1,'a' do \n print(i) \n end", 2) 305lineerror("local a\n for i=1,'a' do \n print(i) \n end", 2)
@@ -350,6 +350,23 @@ X=1;lineerror((p), 2)
350X=2;lineerror((p), 1) 350X=2;lineerror((p), 1)
351 351
352 352
353lineerror([[
354local b = false
355if not b then
356 error 'test'
357end]], 3)
358
359lineerror([[
360local b = false
361if not b then
362 if not b then
363 if not b then
364 error 'test'
365 end
366 end
367end]], 5)
368
369
353if not _soft then 370if not _soft then
354 -- several tests that exaust the Lua stack 371 -- several tests that exaust the Lua stack
355 collectgarbage() 372 collectgarbage()