luaflow
luaflow copied to clipboard
"Unexpected tag" error when parsing a call to an unnamed function
When running luaflow on this file, I get the error "Unexpected tag".
It works fine on other files I've tried, but not this one.
19:33:24
sargunv@lincastle ~/Desktop luaflow -g miner.lua
/usr/bin/lua5.1: /usr/local/share/lua/5.1/luaflow_lib.lua:127: Unexpected tag, t: {"1":{"1":{"2":{"2":{"1":"force","tag":"Id","pos":7948},"3":{"1":"forceMove","tag":"Id","pos":7958},"1":"and","pos":7948,"tag":"Op"},"3":{"1":{"1":{"1":"component","tag":"Id","pos":7971},"2":{"1":"robot","tag":"String","pos":7981},"pos":7971,"tag":"Index"},"2":{"1":"move","tag":"String","pos":7987},"pos":7971,"tag":"Index"},"1":"or","pos":7948,"tag":"Op"},"tag":"Paren","pos":7947},"2":{"1":"side","tag":"Id","pos":7993},"3":{"1":1,"tag":"Number","pos":7999},"pos":7947,"tag":"Call"}
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/luaflow_lib.lua:127: in function 'enter'
/usr/local/share/lua/5.1/luaflow_lib.lua:150: in function 'visit'
/usr/local/share/lua/5.1/luaflow_lib.lua:155: in function 'visit'
/usr/local/share/lua/5.1/luaflow_lib.lua:155: in function 'visit'
/usr/local/share/lua/5.1/luaflow_lib.lua:155: in function 'visit'
/usr/local/share/lua/5.1/luaflow_lib.lua:155: in function 'visit'
/usr/local/share/lua/5.1/luaflow_lib.lua:155: in function 'visit'
/usr/local/share/lua/5.1/luaflow_lib.lua:155: in function 'visit'
/usr/local/share/lua/5.1/luaflow_lib.lua:155: in function 'visit'
/usr/local/share/lua/5.1/luaflow_lib.lua:383: in function 'visit_tree'
...local/lib/luarocks/rocks/luaflow/0.1.4-1/bin/luaflow:184: in function 'main'
...local/lib/luarocks/rocks/luaflow/0.1.4-1/bin/luaflow:204: in main chunk
[C]: ?
I've found the specific code that triggers the error; it's line 225 in the example file I linked above:
local result, reason = (force and forceMove or component.robot.move)(side, 1)
Here's a minimal example that causes the error:
-- testing.lua
function foo()
end
function bar()
return foo
end
bar()()
19:43:00
sargunv@lincastle ~/Desktop luaflow -d testing.lua
/usr/bin/lua5.1: /usr/local/share/lua/5.1/luaflow_lib.lua:127: Unexpected tag, t: {"1":{"1":{"1":"bar","tag":"Id","pos":54},"pos":54,"tag":"Call"},"pos":54,"tag":"Call"}
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/luaflow_lib.lua:127: in function 'enter'
/usr/local/share/lua/5.1/luaflow_lib.lua:150: in function 'visit'
/usr/local/share/lua/5.1/luaflow_lib.lua:155: in function 'visit'
/usr/local/share/lua/5.1/luaflow_lib.lua:383: in function 'visit_tree'
...local/lib/luarocks/rocks/luaflow/0.1.4-1/bin/luaflow:184: in function 'main'
...local/lib/luarocks/rocks/luaflow/0.1.4-1/bin/luaflow:204: in main chunk
[C]: ?
It seems luaflow has trouble handling the case when a function without a name is called.