@@ -87,7 +87,9 @@ local searchFieldSwitch = util.switch()
8787 : call (function (suri , node , key , pushResult )
8888 -- change to `string: stringlib` ?
8989 local stringlib = globalMgr .getGlobal (' type' , ' stringlib' )
90- m .getClassFields (suri , stringlib , key , pushResult )
90+ if stringlib then
91+ m .getClassFields (suri , stringlib , key , pushResult )
92+ end
9193 end )
9294 : case ' local'
9395 : call (function (suri , node , key , pushResult )
@@ -302,8 +304,8 @@ function m.getReturnOfFunction(func, index)
302304end
303305
304306local function getReturnOfSetMetaTable (args )
305- local tbl = args and args [1 ]
306- local mt = args and args [2 ]
307+ local tbl = args [1 ]
308+ local mt = args [2 ]
307309 local node = union ()
308310 if tbl then
309311 node :merge (m .compileNode (tbl ))
@@ -325,23 +327,35 @@ end
325327
326328local function getReturn (func , index , args )
327329 if func .special == ' setmetatable' then
330+ if not args then
331+ return nil
332+ end
328333 return getReturnOfSetMetaTable (args )
329334 end
330335 if func .special == ' pcall' and index > 1 then
336+ if not args then
337+ return nil
338+ end
331339 local newArgs = {}
332340 for i = 2 , # args do
333341 newArgs [# newArgs + 1 ] = args [i ]
334342 end
335343 return getReturn (args [1 ], index - 1 , newArgs )
336344 end
337345 if func .special == ' xpcall' and index > 1 then
346+ if not args then
347+ return nil
348+ end
338349 local newArgs = {}
339350 for i = 3 , # args do
340351 newArgs [# newArgs + 1 ] = args [i ]
341352 end
342353 return getReturn (args [1 ], index - 1 , newArgs )
343354 end
344355 if func .special == ' require' then
356+ if not args then
357+ return nil
358+ end
345359 local nameArg = args [1 ]
346360 if not nameArg or nameArg .type ~= ' string' then
347361 return nil
@@ -941,9 +955,11 @@ local compilerSwitch = util.switch()
941955 -- initValue
942956 selectNode (source ._iterArgs [2 ], source .exps , 3 )
943957 end
944- for i , loc in ipairs (source .keys ) do
945- local node = getReturn (source ._iterator , i , source ._iterArgs )
946- nodeMgr .setNode (loc , node )
958+ if source .keys then
959+ for i , loc in ipairs (source .keys ) do
960+ local node = getReturn (source ._iterator , i , source ._iterArgs )
961+ nodeMgr .setNode (loc , node )
962+ end
947963 end
948964 end )
949965 : case ' doc.type'
@@ -1360,7 +1376,7 @@ local compilerSwitch = util.switch()
13601376 if source .op .type == ' //' then
13611377 local a = valueMgr .getNumber (source [1 ])
13621378 local b = valueMgr .getNumber (source [2 ])
1363- if a and b then
1379+ if a and b and b ~= 0 then
13641380 local result = a // b
13651381 nodeMgr .setNode (source , {
13661382 type = math.type (result ) == ' integer' and ' integer' or ' number' ,
0 commit comments