EmmyLua / VSCode-EmmyLua

Lua IDE/Debugger Plugin for VSCode
641 stars 95 forks source link

对函数返回的local table修改,会错误绑定修改的键值对 #149

Closed weiyuan-19 closed 5 months ago

weiyuan-19 commented 5 months ago

Environment(环境)

name version
VSCode version 1.89.1
EmmyLua version v0.7.2
OS OSX 12.3

What are the steps to reproduce this issue?(重现步骤?)

function test_func()
    local tb = {}
    return tb
end

local a = test_func()
a.test_a = 1
a.test_a2 = 2

local b = test_func()
b.test_b = 3

What happens?(出现什么问题?)

函数里的local tb错误绑定了a、b设置的键值对,同样a、b也认为自己是同一个table image image image image

What were you expecting to happen?(期望?)

函数里的tb不应该绑定外面的修改?是否有什么特殊的场景需要如此? a、b应该为两个不同table,各自修改应互不影响

Any logs, error output, etc?(有没有什么log, error输出?)

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Any other comments?(其它说明)

CppCXY commented 5 months ago

对动态类型语言来讲, 我不知道什么是实例什么是模板, 而在lua中更多使用的是模块, 模板和实例不存在区分, 所以我无法对这种情况做出假设