From c268c130f7eaa493296357b1bd0ce14eb67626a2 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, 26 Oct 2020 11:04:16 +0800 Subject: =?UTF-8?q?in=E5=92=8Cloop=E6=94=AF=E6=8C=81doc.param?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/parser/guide.lua | 16 ++++++++++------ test-beta/hover/init.lua | 6 +++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 694d37d0..98146386 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -2546,13 +2546,17 @@ function m.inferCheckDoc(status, source) status.results[#status.results+1] = res end elseif doc.type == 'doc.param' then + -- function (x) 的情况 if source.type == 'local' - and m.getName(source) == doc.param[1] - and source.parent.type == 'funcargs' then - status.results[#status.results+1] = { - type = m.viewInferType(m.getDocTypeNames(doc.extends)), - source = doc, - } + and m.getName(source) == doc.param[1] then + if source.parent.type == 'funcargs' + or source.parent.type == 'in' + or source.parent.type == 'loop' then + status.results[#status.results+1] = { + type = m.viewInferType(m.getDocTypeNames(doc.extends)), + source = doc, + } + end end end end diff --git a/test-beta/hover/init.lua b/test-beta/hover/init.lua index ac38edb5..119e1ee1 100644 --- a/test-beta/hover/init.lua +++ b/test-beta/hover/init.lua @@ -939,7 +939,6 @@ end local t: Class ]] -do return end TEST [[ ---@class Class @@ -948,7 +947,7 @@ for in pairs(t) do end ]] [[ -local k: Class {} +local k: Class ]] TEST [[ @@ -959,9 +958,10 @@ for k, in pairs(t) do end ]] [[ -local v: *Class {} +local v: Class ]] +do return end TEST [[ ---@return A|B ---@return C -- cgit v1.2.3