@@ -87,7 +87,9 @@ local searchFieldSwitch = util.switch()
87
87
: call (function (suri , node , key , pushResult )
88
88
-- change to `string: stringlib` ?
89
89
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
91
93
end )
92
94
: case ' local'
93
95
: call (function (suri , node , key , pushResult )
@@ -302,8 +304,8 @@ function m.getReturnOfFunction(func, index)
302
304
end
303
305
304
306
local 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 ]
307
309
local node = union ()
308
310
if tbl then
309
311
node :merge (m .compileNode (tbl ))
@@ -325,23 +327,35 @@ end
325
327
326
328
local function getReturn (func , index , args )
327
329
if func .special == ' setmetatable' then
330
+ if not args then
331
+ return nil
332
+ end
328
333
return getReturnOfSetMetaTable (args )
329
334
end
330
335
if func .special == ' pcall' and index > 1 then
336
+ if not args then
337
+ return nil
338
+ end
331
339
local newArgs = {}
332
340
for i = 2 , # args do
333
341
newArgs [# newArgs + 1 ] = args [i ]
334
342
end
335
343
return getReturn (args [1 ], index - 1 , newArgs )
336
344
end
337
345
if func .special == ' xpcall' and index > 1 then
346
+ if not args then
347
+ return nil
348
+ end
338
349
local newArgs = {}
339
350
for i = 3 , # args do
340
351
newArgs [# newArgs + 1 ] = args [i ]
341
352
end
342
353
return getReturn (args [1 ], index - 1 , newArgs )
343
354
end
344
355
if func .special == ' require' then
356
+ if not args then
357
+ return nil
358
+ end
345
359
local nameArg = args [1 ]
346
360
if not nameArg or nameArg .type ~= ' string' then
347
361
return nil
@@ -941,9 +955,11 @@ local compilerSwitch = util.switch()
941
955
-- initValue
942
956
selectNode (source ._iterArgs [2 ], source .exps , 3 )
943
957
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
947
963
end
948
964
end )
949
965
: case ' doc.type'
@@ -1360,7 +1376,7 @@ local compilerSwitch = util.switch()
1360
1376
if source .op .type == ' //' then
1361
1377
local a = valueMgr .getNumber (source [1 ])
1362
1378
local b = valueMgr .getNumber (source [2 ])
1363
- if a and b then
1379
+ if a and b and b ~= 0 then
1364
1380
local result = a // b
1365
1381
nodeMgr .setNode (source , {
1366
1382
type = math.type (result ) == ' integer' and ' integer' or ' number' ,
0 commit comments