Skip to content

Commit d388384

Browse files
committed
Revert "infer parameter type by return"
This reverts commit 2873cca.
1 parent 2873cca commit d388384

File tree

3 files changed

+1
-35
lines changed

3 files changed

+1
-35
lines changed

changelog.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ server will generate `doc.json` and `doc.md` in `LOGPATH`.
2828
---@type myClass
2929
local class
3030

31-
print(class.a.b.c.e.f.g) --> inferred as integer
31+
print(class.a.b.c.e.f.g) --> infered as integer
3232
```
3333
* `CHG` [#1582] the following diagnostics consider `overload`
3434
* `missing-return`
@@ -58,14 +58,6 @@ server will generate `doc.json` and `doc.md` in `LOGPATH`.
5858

5959
local arr = x(cb) --> `arr` is inferred as `integer[]`
6060
```
61-
* `CHG` [#1202] infer parameter type by expected returned function of parent function
62-
```lua
63-
---@return fun(x: integer)
64-
local function f()
65-
return function (x) --> `x` is inferred as `integer`
66-
end
67-
end
68-
```
6961
* `FIX` [#1567]
7062
* `FIX` [#1593]
7163
* `FIX` [#1595]
@@ -78,7 +70,6 @@ server will generate `doc.json` and `doc.md` in `LOGPATH`.
7870

7971
[#1153]: https://github.com/sumneko/lua-language-server/issues/1153
8072
[#1177]: https://github.com/sumneko/lua-language-server/issues/1177
81-
[#1202]: https://github.com/sumneko/lua-language-server/issues/1202
8273
[#1458]: https://github.com/sumneko/lua-language-server/issues/1458
8374
[#1557]: https://github.com/sumneko/lua-language-server/issues/1557
8475
[#1558]: https://github.com/sumneko/lua-language-server/issues/1558

script/vm/compiler.lua

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,6 @@ local function compileLocal(source)
10591059
end
10601060
if source.parent.type == 'funcargs' and not hasMarkDoc and not hasMarkParam then
10611061
local func = source.parent.parent
1062-
-- local call ---@type fun(f: fun(x: number));call(function (x) end) --> x -> number
10631062
local funcNode = vm.compileNode(func)
10641063
local hasDocArg
10651064
for n in funcNode:eachObject() do
@@ -1159,22 +1158,6 @@ local compilerSwitch = util.switch()
11591158
local call = source.parent.parent
11601159
vm.compileCallArg(source, call)
11611160
end
1162-
1163-
-- function f() return function (<?x?>) end end
1164-
if source.parent.type == 'return' then
1165-
for i, ret in ipairs(source.parent) do
1166-
if ret == source then
1167-
local func = guide.getParentFunction(source.parent)
1168-
if func then
1169-
local returnObj = vm.getReturnOfFunction(func, i)
1170-
if returnObj then
1171-
vm.setNode(source, vm.compileNode(returnObj))
1172-
end
1173-
end
1174-
break
1175-
end
1176-
end
1177-
end
11781161
end)
11791162
: case 'paren'
11801163
: call(function (source)

test/type_inference/init.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3858,11 +3858,3 @@ local cb
38583858
38593859
local <?arr?> = x(cb)
38603860
]]
3861-
3862-
TEST 'integer' [[
3863-
---@return fun(x: integer)
3864-
local function f()
3865-
return function (<?x?>)
3866-
end
3867-
end
3868-
]]

0 commit comments

Comments
 (0)