diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-02-26 17:04:38 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-02-26 17:04:38 +0800 |
commit | 0ded390ce1b477e62963e8e67488b00ba8427a35 (patch) | |
tree | a11b5fe47930c668c6640eec3391e25ca04a27bf /script/parser/guide.lua | |
parent | 2c688721092f1fe102514eed6a836ccfeb12a789 (diff) | |
download | lua-language-server-0ded390ce1b477e62963e8e67488b00ba8427a35.zip |
improve infer cross `pairs`
Diffstat (limited to 'script/parser/guide.lua')
-rw-r--r-- | script/parser/guide.lua | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 67a41d41..16aea8f1 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -1677,6 +1677,19 @@ local function stepRefOfGenericCrossTable(status, doc, typeName) end end +local function getIteratorArg(status, args, index) + local call = args.parent + local node = call.node + if not node.iterator then + return nil + end + if node.type ~= 'call' then + return nil + end + local results = m.checkSameSimpleInCallInSameFile(status, node.node, node.args, index + 1) + return results[1] +end + local function stepRefOfGeneric(status, typeUnit, args, mode) local results = {} if not args then @@ -1723,7 +1736,13 @@ local function stepRefOfGeneric(status, typeUnit, args, mode) end end - appendValidGenericType(results, status, typeName, crossTable(args[genericIndex])) + local callArg = args[genericIndex] + or getIteratorArg(status, args, genericIndex) + + if not callArg then + goto CONTINUE + end + appendValidGenericType(results, status, typeName, crossTable(callArg)) ::CONTINUE:: end return results |