diff options
author | Soumith Chintala <soumith@gmail.com> | 2015-04-26 22:59:28 +0300 |
---|---|---|
committer | Soumith Chintala <soumith@gmail.com> | 2015-04-26 22:59:28 +0300 |
commit | fea2373035581bcbcc4c7b232d1ba7c9df507b36 (patch) | |
tree | 41312dbd4ccad22649fff3271daf369a97b30856 | |
parent | d6e36a788588686e597aa55e8e8c46139c52bea1 (diff) | |
parent | 6bbe44f717266dfd1c24908a4feefd5df063ee97 (diff) |
Merge pull request #20 from adamlerer/traceback
Improve error stack trace from trepl.
-rw-r--r-- | init.lua | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -615,10 +615,14 @@ function repl() local err if not (line:find(';%s-$') or line:find('^%s-print')) then -- Try to compile statement with "return", to auto-print - local parsed = loadstring('local f = function() return '..line..' end local res = {f()} print(unpack(res)) table.insert(_RESULTS,res[1])') + local parsed = loadstring('local f = function() return '..line..' end') if parsed then - local ok,err = xpcall(parsed, traceback) - if not ok then + local parsed = loadstring('_RESULT={'..line..'}') + local ok,err=xpcall(parsed, traceback) + if ok then + print(unpack(_RESULT)) + table.insert(_RESULTS,_RESULT[1]) + else print(err) end done = true |