From 02f6831344efd3a32c0ac8a1fbd0d00af3dec671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 30 Jan 2023 12:38:03 +0800 Subject: fix wrong infer of tableindex #1831 --- script/vm/infer.lua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'script/vm/infer.lua') diff --git a/script/vm/infer.lua b/script/vm/infer.lua index 74cab4ed..0b20700c 100644 --- a/script/vm/infer.lua +++ b/script/vm/infer.lua @@ -555,19 +555,14 @@ function vm.viewKey(source, uri) return '[' .. key .. ']' end end - if source.type == 'tableindex' then + if source.type == 'tableindex' + or source.type == 'setindex' then local index = source.index - local name = vm.getKeyName(index) + local name = vm.getInfer(index):viewLiterals() if not name then return nil end - local key - if index.type == 'string' then - key = util.viewString(name, index[2]) - else - key = util.viewLiteral(name) - end - return ('[%s]'):format(key), name + return ('[%s]'):format(name), name end if source.type == 'tableexp' then return ('[%d]'):format(source.tindex), source.tindex -- cgit v1.2.3