diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index ba0bdc299..5bbe5e155 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -1824,7 +1824,7 @@ local function our_require(modname, ...) local gvmodi = module_gvlocali[modname] - if (gvmodi and gvmodi[2]>=gvmodi[1]) then + if (gvmodi and gvmodi[2] and gvmodi[2]>=gvmodi[1]) then if (coroutine.status(modthread)=="suspended") then -- Save off the suspended thread so that we may get its locals later on. -- It is never resumed, but only ever used for debug.getlocal(). diff --git a/polymer/eduke32/source/lunatic/test.elua b/polymer/eduke32/source/lunatic/test.elua index 63bf31002..7e4f14ae5 100644 --- a/polymer/eduke32/source/lunatic/test.elua +++ b/polymer/eduke32/source/lunatic/test.elua @@ -107,13 +107,32 @@ checkfail('print(gv.sprite[0])', "access forbidden") -- set metatable forbidden checkfail('setmetatable(sprite, {})', "attempt to read undeclared variable 'setmetatable'") --- OOB write access. --- Note that indexing ("reading") sector fails, even if the user wants to --- assign to a sector member. Potentially confusing error message. -checkfail('sector[-1].ceilingpal = 4', "out-of-bounds sector[] read access") +gameevent +{ + "ENTERLEVEL", --- wallnum member is read-only -checkfail('sector[0].wallnum = 0', "attempt to write to constant location") -- this comes from LJ/FFI + function() + -- OOB write access. + -- Note that indexing ("reading") sector fails, even if the user wants to + -- assign to a sector member. Potentially confusing error message. + checkfail('sector[-1].ceilingpal = 4', "out-of-bounds sector[] read access") + + -- wallnum member is read-only + checkfail('sector[0].wallnum = 0', "attempt to write to constant location") -- this comes from LJ/FFI + + -- direct sector write access forbidden + checkfail('sector[4] = sector[6]', "cannot write directly to sector[]") + + -- creating new keys forbidden... handled by LuaJIT + checkfail('wall[4].QWE = 123', "has no member named 'QWE'") + + -- no pointer arithmetic! + checkfail('local spr = sprite[0]; local x=spr+1', "attempt to perform arithmetic on") + + -- actor[].t_data[] is not accessible for now + checkfail('local i = actor[0].t_data[15]', "has no member named 't_data'") + end +} -- gv.numsectors is read-only checkfail('gv.numsectors = 4', "attempt to write to constant location") @@ -121,18 +140,12 @@ checkfail('gv.numsectors = 4', "attempt to write to constant location") -- cannot create new fields in 'gv' checkfail('gv.QWE = 4', "write access forbidden") --- direct sector write access forbidden -checkfail('sector[4] = sector[6]', "cannot write directly to sector[]") - -- that would be horrible... checkfail('sprite._nextspritesect[4] = -666', "cannot write directly to nextspritesect[]") -- we're indexing a plain array! checkfail('print(sprite._nextspritesect[4].whatfield)', "attempt to index a number value") --- creating new keys forbidden... handled by LuaJIT -checkfail('wall[4].QWE = 123', "has no member named 'QWE'") - -- our 'require' has only safe stuff --checkfail("require('os')") @@ -162,12 +175,6 @@ checkfail('gv.luaJIT_setmode(nil, 0, 0)', "missing declaration for symbol 'luaJI checkfail('gv.luaJIT_BC_con_lang', "attempt to call a nil value") checkfail('gv.gethiticks = nil', "attempt to write to constant location") --- actor[].t_data[] is not accessible for now -checkfail('local i = actor[0].t_data[15]', "has no member named 't_data'") - --- no pointer arithmetic! -checkfail('local spr = sprite[0]; local x=spr+1', "attempt to perform arithmetic on") - checkfail('gameactor{1680, 0}', "must provide a function with last numeric arg or .func") checkfail("do local bt=require'test.test_bitar'; bt.QWE=1; end", "modifying module table forbidden") diff --git a/polymer/eduke32/source/lunatic/test/test_bitar.lua b/polymer/eduke32/source/lunatic/test/test_bitar.lua index 5855a6f02..bcf902084 100755 --- a/polymer/eduke32/source/lunatic/test/test_bitar.lua +++ b/polymer/eduke32/source/lunatic/test/test_bitar.lua @@ -2,6 +2,7 @@ -- Usage: luajit bittest.lua [-ffi] [-bchk] +local require = require local string = require "string" local math = require "math"