Comments (4)
script/vm/compiler.lua
compileLocal
if source.parent.type == 'funcargs' and not hasMarkDoc and not hasMarkParam then
local func = source.parent.parent
-- local call ---@type fun(f: fun(x: number));call(function (x) end) --> x -> number
local funcNode = vm.compileNode(func)
local hasDocArg
for n in funcNode:eachObject() do
if n.type == 'doc.type.function' then
for index, arg in ipairs(n.args) do
if func.args[index] == source then
local argNode = vm.compileNode(arg)
for an in argNode:eachObject() do
if an.type ~= 'doc.generic.name' then
vm.setNode(source, an)
end
end
hasDocArg = true
end
end
end
end
if not hasDocArg then
local refs = vm.getRefs(source.parent.parent)
local findCall
if refs then
for i, ref in ipairs(refs) do
if ref.parent.type == 'call' then
findCall = ref.parent
break
end
end
end
if findCall then
local index
for i, arg in ipairs(source.parent) do
if arg == source then
index = i
break
end
end
if index then
hasDocArg = true
local callerArg = findCall.args[index]
vm.setNode(source, vm.compileNode(callerArg))
end
end
end
if not hasDocArg then
vm.setNode(source, vm.declareGlobal('type', 'any'))
end
end
It's worked
from lua-language-server.
vm.getRefs
may very slow
from lua-language-server.
It is indeed slow, so one should limit the search in which way.
I think first just find the first valid function call.
from lua-language-server.
Limiting types to local variables,maybe better
from lua-language-server.
Related Issues (20)
- Function Prototype Narrowing with nils HOT 2
- Overload intellisense issue with type of parameters
- Overload intellise prototype issue with meta functions HOT 2
- `inject-field` error (`exact`) is not working as expected? HOT 4
- Typed field overrides the type of other fields HOT 1
- The type is not determined after the bitwise operation HOT 1
- [Feature Request] Option for automatic requires to use class name
- When defining global variable using `---@class _G` + `---@field`, no autocompletion in `_G.*` for those injected fields
- Lua lsp using too much RAM on specific files HOT 1
- Need help with running lua lsp in a docker container HOT 3
- [Suggestion] Add ability to define an enum without using a table HOT 3
- Accessing deeply nested variable at 'if' statemet cause type collision HOT 6
- Getting a cast warning when it should be fine
- Casting warning when there should be none. HOT 2
- [ANN] IntelliJ-SumnekoLua base on LSP4IJ has released HOT 8
- Standard way to annotate `---@return void` - aka "does not return anything"? HOT 6
- Using `diagnostics.severity` setting in `.luarc.json` seems to break the severity level filtering in generated report HOT 1
- Type checking does not work at all with `` (backtick) literals
- False negative for param-type-mismatch when using a variable as argument
- Missing fields not working for inherited classes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-language-server.