lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Jan 2, 2012 at 6:56 PM, Jeff Smith <spammealot1@live.co.uk> wrote:
> Issue 3
>
> a) Simple test scripts all seem to compile to bytecode OK (luaL_loadfile()
> returns 0 )
>
> b) I get run time errors as follows:
>
> print(1) --> gives "Lua Error: attempt to call a table value"
>
> a=os.clock() --> gives "Lua Error: C:\test.lua:2: attempt to call field
> 'clock' (a nil value)"
>
> a=math.abs(-2) --> gives "Lua Error: C:\test.lua:1: attempt to call field
> 'abs' (a nil value)"
>
>
> If I run a script
> a=1
> b=2
> c=a+b
> This runs OK, lua_pcall(L,0,0) returns 0
>
>
> So far I am guessing that the global table _G (or maybe the baselibs) is
> either not getting set up properly or is subsequently getting
> cleared/trashed. Debugging is a bit problematic as I cant get the Lua
> print() to work so cant see very easily what the _G table looks like.

My initial guess would be that something is overwriting
LUA_RIDX_GLOBALS in the registry. As per the manual [1], doing
anything with integer keys in the registry is discouraged, as doing so
can interfere with these RIDX values or with the auxiliary library
reference system.

[1] http://www.lua.org/manual/5.2/manual.html#4.5