Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/trepl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2015-04-26 22:59:28 +0300
committerSoumith Chintala <soumith@gmail.com>2015-04-26 22:59:28 +0300
commitfea2373035581bcbcc4c7b232d1ba7c9df507b36 (patch)
tree41312dbd4ccad22649fff3271daf369a97b30856
parentd6e36a788588686e597aa55e8e8c46139c52bea1 (diff)
parent6bbe44f717266dfd1c24908a4feefd5df063ee97 (diff)
Merge pull request #20 from adamlerer/traceback
Improve error stack trace from trepl.
-rw-r--r--init.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/init.lua b/init.lua
index 75961be..c4a83f6 100644
--- a/init.lua
+++ b/init.lua
@@ -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