-
-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix table array infer #2924
Fix table array infer #2924
Conversation
考虑到如果存在一个较大的配置表, 强行分析table元素的类型通常是无意义的 |
能够理解你的意思,我接触到的项目中,配置表一般都用以下的方法去定义 local conf = {
[1] = {id = 1,},
[2] = {id = 2,},
...
}
return conf 如果真的确实很大,理论上上述的 |
以我的经验来看,不是所有人都愿意配置, 另外我更倾向于你的这个行为通过配置开关, 而不是直接启用 |
👀 我 checkout 了這個 PR 來測試,發現還可以 fix 到 #2922 呢 👍 該 issue 是 generic
如果有個 config,並且 default 為關掉的話,可能大多數人一開始不會意識到是跟這 config 有關 會否可以這樣呢:
|
我覺得可以 👍 |
script/vm/type.lua
Outdated
@@ -655,9 +655,10 @@ function vm.getTableValue(uri, tnode, knode, inversion) | |||
end | |||
end | |||
end | |||
local inferSize = config.get(uri, "Lua.type.inferTableSize") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這個可以在最開首,forloop 外邊就獲取?
沒有必要每次 loop 都重新 get 1次 🤔
让我们键入以上的代码,我认为t1和t2两个数组的结果是一样的,但是结果是变量a和变量b的提示并不一样。



变量a给我的代码提示是我能够接受的,
但是b给我的代码提示是错误的,始终把
local b = t2[idx]
等价解析为local b = t2[1]
,这并不完全正确,通过阅读源码,我并不知道为什么针对tableexp类型还要加上
field.tindex == 1
这样的判断,但将其去除后代码提示就正确了。