debug.getlocal return wrong name, values when there is a for block #252
Open
Description
- GopherLua is a Lua5.1 implementation. You should be familiar with Lua programming language. Have you read Lua 5.1 reference manual carefully?
- GopherLua is a Lua5.1 implementation. In Lua, to keep it simple, it is more important to remove functionalities rather than to add functionalities unlike other languages . If you are going to introduce some new cool functionalities into the GopherLua code base and the functionalities can be implemented by existing APIs, It should be implemented as a library.
Please answer the following before submitting your issue:
- What version of GopherLua are you using? :
- What version of Go are you using? :
- What operating system and processor architecture are you using? :
- What did you do? :
- What did you expect to see? :
- What did you see instead? :
the test code is
local t = {aa = 1, bb = 2}
for k, v in pairs(t) do
print(k, v)
end
local a = 1
local b = 2
local c = a+b
local x = 1
while true do
local name, value = debug.getlocal(1, x)
if not name then
break
end
print(name, value)
x = x + 1
end
and the output is
aa 1
bb 2
t table: 0xc00006c420
(for generator) 1
(for state) 2
(for control) 3
k 5
v function: 0xc000118700
a 1
the debug.getlocal(1, x) cannot get vars like b, c, x.
hope to fix this.
Metadata
Assignees
Labels
No labels