franko / luajit-lang-toolkit

A Lua bytecode compiler written in Lua itself for didactic purposes or for new language implementations
Other
654 stars 91 forks source link

problem with compiling function with empty body #2

Closed umegaya closed 10 years ago

umegaya commented 10 years ago

hi, I think there is great possibility for luajit-lang-toolkit. thank you for your great work :D I try to use luajit-lang-toolkit to implement some programming languages. but when I generate lua AST which expresses the lua function with empty body, I got error.

with further investigation I reproduce same problem with following simple lua source.

is it known problem or I was missing something about limitation of luajit-lang-toolkit?

regards.

$ git log -1
commit 3800c1ad46039b149c50eb2d0c552c563abcd179
Author: Francesco Abbate <francesco.bbt@gmail.com>
Date:   Sun Mar 30 17:19:26 2014 +0200

    Fix problems with test scripts when checking luajit
$ luajit -v
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
$ cat tests/func-simple-body.lua 
local func = function () print(1) end
$ luajit tests/func-simple-body.lua 
$ luajit run.lua tests/func-simple-body.lua 
$ cat tests/func-empty.lua 
local func = function () end
$ luajit tests/func-empty.lua 
$ luajit run.lua tests/func-empty.lua 
luajit: ./compile.lua:11: ./generator.lua:900: attempt to index local 'node' (a nil value)
stack traceback:
    [C]: in function 'error'
    ./compile.lua:11: in function 'file'
    run.lua:55: in main chunk
    [C]: at 0x01000010d0
franko commented 10 years ago

Hi, thank you for reporting that, it is now fixed in the master branch with commit

https://github.com/franko/luajit-lang-toolkit/commit/838b951f65899330a6b707cde96582b5f795abe3

I've also added a specific test for this case in the test suite. You may interested to know that you can run the test suite with:

python tests/test-output.py

and

python tests/test-bytecode.py

Francesco

umegaya commented 10 years ago

hi, sorry for late reply, I also can confirm this problem solved. thank you for your quick response!!