cannot correctly parse return statement
description
The DocumentParser.Parse method sometimes cannot correctly parse the return statement in any block. If there are any statements before the return statement, the return keyword (KWRETURN) might be considered syntaxtical illegal.
I can figured this problem out by going deeply into the parser code, but cannot tell how to fix it. I tried to modify the parser.y file but failed.
Parsing the following Lua code will recreate this issue:
-- The following code can be correctly parsed
function foo()
return 3
end
-- The following code will be parsed with the return statement lost
function foo()
local a = 3
return a
end