lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Generics Super Issue

Open carsakiller opened this issue 2 years ago • 7 comments

This "super issue" serves to organize and track all the issues relating to the implementation of generics.

Some of the following issues are likely duplicates, so some may just need to be marked duplicate and linked to other issues.

  • [ ] https://github.com/sumneko/lua-language-server/issues/723
  • [ ] https://github.com/sumneko/lua-language-server/issues/734
  • [ ] https://github.com/sumneko/lua-language-server/issues/911
  • [ ] https://github.com/sumneko/lua-language-server/issues/1000
  • [ ] https://github.com/sumneko/lua-language-server/issues/1170
  • [ ] https://github.com/sumneko/lua-language-server/issues/1272
  • [ ] https://github.com/sumneko/lua-language-server/issues/1322
  • [ ] https://github.com/sumneko/lua-language-server/issues/1341
  • [ ] https://github.com/sumneko/lua-language-server/issues/1532
  • [ ] https://github.com/sumneko/lua-language-server/issues/1853
  • [ ] https://github.com/sumneko/lua-language-server/issues/1856
  • [ ] https://github.com/sumneko/lua-language-server/issues/1863
  • [ ] https://github.com/LuaLS/lua-language-server/issues/1883
  • [ ] https://github.com/LuaLS/lua-language-server/issues/1929
  • [x] https://github.com/LuaLS/lua-language-server/issues/1935

carsakiller avatar Jan 30 '23 15:01 carsakiller

thanks for putting all these in one place. i found some more edge cases; maybe some of them are listed here already but i'll try to document them more diligently.

bandaloo avatar Jan 31 '23 20:01 bandaloo

When will it get done?

jakitliang avatar Dec 02 '23 12:12 jakitliang

Here's another issue with generics that I don't believe has been documented yet?

---@class A
---@field k string

---@generic T: A
---@param p1 T
function f(p1) local m = p1.k end

^^^ here p1 should have a type of A within the function, but it doesn't, therefore m receives the type unknown

tmillr avatar Jan 29 '24 21:01 tmillr

Here's another issue with generics that I don't believe has been documented yet?

---@class A
---@field k string

---@generic T: A
---@param p1 T
function f(p1) local m = p1.k end

^^^ here p1 should have a type of A within the function, but it doesn't, so m receives the type unknown

This is odd since this use case works but you have to use the parameter capture for the generic to get its type and it also only works with base Lua types and not custom classes see #2355 description

checkraisefold avatar Jun 27 '24 04:06 checkraisefold

Here's another issue with generics that I don't believe has been documented yet?

---@class A
---@field k string

---@generic T: A
---@param p1 T
function f(p1) local m = p1.k end

^^^ here p1 should have a type of A within the function, but it doesn't, so m receives the type unknown

This is odd since this use case works but you have to use the parameter capture for the generic to get its type and it also only works with base Lua types and not custom classes see #2355 description

I wouldn't really consider that to be "working". Passing strings at runtime just to get the LSP to work correctly is awkward. In theory this should be an easy fix, as the concrete type is literally right there and apart of the function's signature. It's not much different than getting/substituting the type of a concrete @param, there's just an extra layer of indirection (i.e. p1 -> T -> A instead of p1 -> T).

tmillr avatar Jul 10 '24 15:07 tmillr

Here's another issue with generics that I don't believe has been documented yet?

---@class A
---@field k string

---@generic T: A
---@param p1 T
function f(p1) local m = p1.k end

^^^ here p1 should have a type of A within the function, but it doesn't, so m receives the type unknown

This is odd since this use case works but you have to use the parameter capture for the generic to get its type and it also only works with base Lua types and not custom classes see #2355 description

I wouldn't really consider that to be "working". Passing strings at runtime just to get the LSP to work correctly is awkward. In theory this should be an easy fix, as the concrete type is literally right there and apart of the function's signature. It's not much different than getting/substituting the type of a concrete @param, there's just an extra layer of indirection (i.e. p1 -> T -> A instead of p1 -> T).

Oh yeah, definitely not "working" per se but very odd that it works with strings and only base Lua types. I would think it would literally be easier to implement the other way code wise

checkraisefold avatar Jul 10 '24 23:07 checkraisefold