@@ -14,10 +14,15 @@ local vm = require 'vm.vm'
1414--- @field func parser.object
1515
1616-- 该函数有副作用,会给source绑定node!
17+ --- @param source parser.object
18+ --- @return boolean
1719local function bindDocs (source )
20+ local docs = source .bindDocs
21+ if not docs then
22+ return false
23+ end
1824 local isParam = source .parent .type == ' funcargs'
1925 or (source .parent .type == ' in' and source .finish <= source .parent .keys .finish )
20- local docs = source .bindDocs
2126 for i = # docs , 1 , - 1 do
2227 local doc = docs [i ]
2328 if doc .type == ' doc.type' then
@@ -47,6 +52,9 @@ local function bindDocs(source)
4752 end
4853 if doc .type == ' doc.module' then
4954 local name = doc .module
55+ if not name then
56+ return true
57+ end
5058 local uri = rpath .findUrisByRequirePath (guide .getUri (source ), name )[1 ]
5159 if not uri then
5260 return true
@@ -1380,9 +1388,18 @@ local compilerSwitch = util.switch()
13801388 else
13811389 --- @cast key string
13821390 vm .compileByParentNode (source .node , key , false , function (src )
1383- vm .setNode (source , vm .compileNode (src ))
13841391 if src .value then
1385- vm .setNode (source , vm .compileNode (src .value ))
1392+ if bindDocs (src ) then
1393+ vm .setNode (source , vm .compileNode (src ))
1394+ else
1395+ vm .setNode (source , vm .compileNode (src .value ))
1396+ local node = vm .getNode (src )
1397+ if node then
1398+ vm .setNode (source , node )
1399+ end
1400+ end
1401+ else
1402+ vm .setNode (source , vm .compileNode (src ))
13861403 end
13871404 end )
13881405 end
0 commit comments