Skip to content

Commit fcc9046

Browse files
committed
refactor: add isCallable to vm.node
1 parent bcbe3ca commit fcc9046

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

script/core/diagnostics/no-unknown-operations.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ return function (uri, callback)
2121
if inferred ~= 'unknown' then return end
2222
local functionType = vm.getInfer(source.node)
2323
if functionType:view(uri) == 'unknown' then return end -- we can't say anything about what unknown types support
24-
local operators = vm.getOperators("call", source.node)
25-
local canCall = functionType:hasFunction(uri) or #operators ~= 0
26-
if canCall then return end
24+
if functionType:isCallable(uri) then return end
2725
callback {
2826
start = source.start,
2927
finish = source.finish,

script/vm/operator.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,10 @@ local function checkOperators(operators, op, value, result)
9595
end
9696

9797
---@param op string
98-
---@param exp parser.object
98+
---@param node vm.node
9999
---@return parser.object[]
100-
function vm.getOperators(op, exp)
101-
local uri = guide.getUri(exp)
102-
local node = vm.compileNode(exp)
100+
function vm.getOperators(op, node)
101+
local uri = guide.getUri(node)
103102
---@type parser.object[]
104103
local operators = {}
105104
for c in node:eachObject() do
@@ -126,7 +125,8 @@ end
126125
---@param value? parser.object
127126
---@return vm.node?
128127
function vm.runOperator(op, exp, value)
129-
local operators = vm.getOperators(op, exp)
128+
local node = vm.compileNode(exp)
129+
local operators = vm.getOperators(op, node)
130130
---@type vm.node?
131131
local result
132132
for _, operator in ipairs(operators) do

0 commit comments

Comments
 (0)