lua icon indicating copy to clipboard operation
lua copied to clipboard

could not compile - missing import

Open rbucker opened this issue 10 years ago • 12 comments

nim c -r examples/luaex.nim

could not import: lua_equal

rbucker avatar Feb 16 '15 21:02 rbucker

Try --deadCodeElim:on perhaps.

dom96 avatar Feb 16 '15 21:02 dom96

--deadCodeElim:on resulted in

could not import: luaL_loadbuffer

rbucker avatar Feb 16 '15 21:02 rbucker

Which lua do you have 5.1 or 5.2 On Feb 16, 2015 3:48 PM, "richard bucker" [email protected] wrote:

--deadCodeElim:on resulted in

could not import: luaL_loadbuffer

— Reply to this email directly or view it on GitHub https://github.com/nim-lang/lua/issues/2#issuecomment-74577584.

fowlmouth avatar Feb 16 '15 21:02 fowlmouth

> lua -v
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio

rbucker avatar Feb 16 '15 21:02 rbucker

Use lua52 module

fowlmouth avatar Feb 16 '15 21:02 fowlmouth

Old examples may not work depending on the API changes

fowlmouth avatar Feb 16 '15 22:02 fowlmouth

lua52 generated this error:

/Users/richardbu/.nimble/pkgs/lua-1.0/lua52.nim(409, 29) Error: ')' expected

rbucker avatar Feb 16 '15 22:02 rbucker

@rbucker likely a proc param named func, it errors because func is a keyword now.

dom96 avatar Feb 16 '15 23:02 dom96

sounds like it's a no go?

rbucker avatar Feb 16 '15 23:02 rbucker

Change it and create a PR please.

dom96 avatar Feb 16 '15 23:02 dom96

I started working on the PR and then...

/Users/richardbu/.nimble/pkgs/lua-1.0/lua52.nim(634, 41) Warning: 'l' should not be used as an identifier; may look like '1' (one) [SmallLshouldNotBeUsed]
/Users/richardbu/.nimble/pkgs/lua-1.0/lua52.nim(658, 8) Warning: use File instead; TFile is deprecated [Deprecated]
/Users/richardbu/.nimble/pkgs/lua-1.0/lua52.nim(665, 45) Warning: 'l' should not be used as an identifier; may look like '1' (one) [SmallLshouldNotBeUsed]
/Users/richardbu/.nimble/pkgs/lua-1.0/lua52.nim(666, 32) Warning: 'l' should not be used as an identifier; may look like '1' (one) [SmallLshouldNotBeUsed]
/Users/richardbu/.nimble/pkgs/lua-1.0/lua52.nim(667, 22) Warning: 'l' should not be used as an identifier; may look like '1' (one) [SmallLshouldNotBeUsed]
/Users/richardbu/.nimble/pkgs/lua-1.0/lua52.nim(13, 2) Hint: 'LUA_RELEASE' is declared but not used [XDeclaredButNotUsed]
luaex.nim(13, 8) Error: undeclared identifier: 'loadbuffer'

I suppose I could fix the warnings, however, the error... not as much fun.

rbucker avatar Feb 16 '15 23:02 rbucker

@rbucker some compatibility functions are in there, luaL_loadbuffer, left as templates because it was tedious to figure out what types they should be, also some of them would conflict with functions defined. loadbuffer would look like this (see luaL_loadbuffer)

proc loadbuffer(L:PState; buff:cstring; sz:csize; name:cstring): cint = 
  loadbufferx(L, buff, sz, name, nil)

can you try compiling the module lua52 itself? there is a test included if you compile the module itself

fowlmouth avatar Feb 17 '15 03:02 fowlmouth