titan-lang / titan

The Titan programming language
http://titan-lang.org
MIT License
406 stars 13 forks source link

Titan Compiler doesn't run (titan-compiler.location module not found) #245

Closed Jictyvoo closed 6 years ago

Jictyvoo commented 6 years ago

Problem

I installed Titan with luarocks for Lua 5.3 But everytime I want to tun compiler, with any file or without a file, appear a error message saying that:

Error

/usr/bin/lua5.3: /usr/local/share/lua/5.3/titan-compiler/checker.lua:3: module 'titan-compiler.location' not found:No LuaRocks module found for titan-compiler.location no field package.preload['titan-compiler.location'] no file '/usr/local/share/lua/5.3/titan-compiler/location.lua' no file '/usr/local/share/lua/5.3/titan-compiler/location/init.lua' no file '/usr/local/lib/lua/5.3/titan-compiler/location.lua' no file '/usr/local/lib/lua/5.3/titan-compiler/location/init.lua' no file '/usr/share/lua/5.3/titan-compiler/location.lua' no file '/usr/share/lua/5.3/titan-compiler/location/init.lua' no file './titan-compiler/location.lua' no file './titan-compiler/location/init.lua' no file '/home/jictyvoo/.luarocks/share/lua/5.3/titan-compiler/location.lua' no file '/home/jictyvoo/.luarocks/share/lua/5.3/titan-compiler/location/init.lua' no file '/usr/local/lib/lua/5.3/titan-compiler/location.so' no file '/usr/lib/x86_64-linux-gnu/lua/5.3/titan-compiler/location.so' no file '/usr/lib/lua/5.3/titan-compiler/location.so' no file '/usr/local/lib/lua/5.3/loadall.so' no file './titan-compiler/location.so' no file '/home/jictyvoo/.luarocks/lib/lua/5.3/titan-compiler/location.so' no file '/usr/local/lib/lua/5.3/titan-compiler.so' no file '/usr/lib/x86_64-linux-gnu/lua/5.3/titan-compiler.so' no file '/usr/lib/lua/5.3/titan-compiler.so' no file '/usr/local/lib/lua/5.3/loadall.so' no file './titan-compiler.so' no file '/home/jictyvoo/.luarocks/lib/lua/5.3/titan-compiler.so' stack traceback: [C]: in function 'require' /usr/local/share/lua/5.3/titan-compiler/checker.lua:3: in main chunk [C]: in function 'require' /usr/local/lib/luarocks/rocks-5.3/titan/dev-1/bin/titanc:5: in main chunk [C]: in ?

Ask

So, how can I make titanc work?

mascarenhas commented 6 years ago

Sorry, the rockspec was missing that file, I am merging a hotfix for that.

mascarenhas commented 6 years ago

While the PR with the fix does not get reviewed and merged you can see the changes at https://github.com/titan-lang/titan/pull/246 and apply them to your local copy

Jictyvoo commented 6 years ago

Hi, thanks for fixing that, but now have other problem. I tried to compile a file containing that

 function divmod(a: integer, b: integer): (integer, integer)
    return a // b, a % b
end

local x, y = divmod(13, 2) -- ok
local x, _ = divmod(13, 2) -- ok

function just_div(a: integer, b: integer): integer
    return (divmod(a, b)) -- ok, arity of divmod is adjusted to 1
end 

but when I execute

titanc test.titan
in same directory that saved the file, titan prints many errors, so I tried to do the same thing that you when make the hotfix. And now doesn't show more require errors, I have pulled here https://github.com/titan-lang/titan/pull/247

but, when I tried to run

titanc examples.sdl_demo -lSDL2
I get this error:

/usr/bin/lua5.3: /usr/local/share/lua/5.3/titan-compiler/coder.lua:2512: bad argument #1 to 'ipairs' (table expected, got nil)
stack traceback:
    [C]: in function 'ipairs'
    /usr/local/share/lua/5.3/titan-compiler/coder.lua:2512: in upvalue 'import_module'
    /usr/local/share/lua/5.3/titan-compiler/coder.lua:2802: in function 'titan-compiler.coder.generate'
    /usr/local/share/lua/5.3/titan-compiler/driver.lua:154: in function 'titan-compiler.driver.compile'
    /usr/local/share/lua/5.3/titan-compiler/driver.lua:133: in function 'titan-compiler.driver.compile_module'
    /usr/local/lib/luarocks/rocks-5.3/titan/dev-1/bin/titanc:57: in main chunk
    [C]: in ?
mascarenhas commented 6 years ago

Obviously it should fail in that way because of that, and I will look into fixing the error message, but there is a sdl_quit.titan module missing in the examples folder that sdl_example.titan is trying to import. @hishamhm, could you check that in?

hishamhm commented 6 years ago

Sure! the file is here: https://github.com/titan-lang/titan/pull/249