LuaLS / LuaLS/lua-language-server
more emmylua enhancements
オープン
まだ誰も着手していません。
enhancement
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
(it's okay to close this if they're not possible, just wondering if they're possible)
- (if possible) support for nice highlighting for
ffi.cdef([[]]), not just the version without parens- (edit: i don't think it's reasonable, seems like it's the builtin highlighting that's doing this)
- erroring on
string + anything,table + anything,anything + string,anything + table - adding enum members to autocomplete
- taking into account the implicit return at the end of a function, into the signature:
-- inferred: nil, string (incorrect)
local function bad()
if 0 > 0 then return nil, "an error" end
end
-- inferred: nil, string | nil (correct), however:
local function bad()
if 0 > 0 then return nil, "an error" end
return -- marked as a redundant return
end
- keeping warning about missing return value for these cases:
- i realize this may be disabled because the user might still be writing the function, but i'd prefer it if it always has the warning, so i can be sure that 0 warnings === it's definitely going to run correctly. so maybe it could be an option
function foo()
end
function foo() end
- retaining flow typing for declarations with initializers:
--- @type foo | nil
local x
x = { foo = 1 }
x.foo -- works
--- @type foo | nil
local x = { foo = 1 }
x.foo -- need check nil (| nil overrides flow typing from the initializer)
- better typechecking in general? examples:
--- @class foo
--- @class bar
--- @param foo foo
local function fn(foo)
end
--- @param foos foo[]
local function fn2(foos)
end
local f --- @type foo
local b --- @type bar
fn(f) -- ok
fn(b) -- error
fn({ f }) -- ok (incorrect)
fn2({ f }) -- ok
fn2(f) -- ok (incorrect)
fn2(b) -- ok (incorrect)
@classsuppresses "global variable in lowercase initial" warning:
--- @class foo
function f()
end
- disallowing assigning decimal literals to integer variables, and numbers to different numbers (it already does this between string/number/table/string literals/integer literals etc.):
- i guess the real issue is not having decimal literal types?
--- @type integer
local foo = 1.1
--- @type 10
local foo = 1.1 -- this should error at least
- disallowing comparisons between incompatible types
- i understand this may be hard, but imo it's useful even in a simple form - e.g. checking if unions have no members that are compatible with each other (somehow...?)
- in my specific case it's just between
string|string[]andnumberso even just handling it only for primitives and arrays would be quite helpful
- in my specific case it's just between
- i understand this may be hard, but imo it's useful even in a simple form - e.g. checking if unions have no members that are compatible with each other (somehow...?)
- recursive types (not necessarily generic) - in my case i have an
@alias tree_node table<string, tree_leaf | tree_node>- i've seen #1161 which seems to imply that recursive generics are too complex - not sure if this applies to normal types
- allow
@type my_function_aliasas an alternative to@param+@return- this may be useful for e.g. request handlers for a web framework
fun(req: request, res: response): nil - it seems to kind of work for
local foo = functionandlocal function foo. doesn't seem to work forreturn function- by "kind of work" - the type of the variable seems to be fine, but it doesn't copy the argument types to the function definition:
- this may be useful for e.g. request handlers for a web framework
--- @type fun(a: integer, b: integer): nil
local function foo(a, b)
-- ^ ^ a: any, b: any
end
- check for missing properties - for example this currently shows no warnings:
--- @type { a: number, b: string }
local foo = {}
- i understand that this may be difficult to do in some cases, but like above, i think even partial support (comparing type to shape at the end of scope, or type at
return, etc) would go a long way
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、この issue で未確認のリクエストと完了した項目を分け、次に、戻り値の推論、型の互換性、再帰型、比較、欠落したプロパティについての Lua の例を再現します。範囲を限定した 1 つの挙動を選び、例に示されている対応する警告または推論結果を基準に完了を定義します。この issue では、ファイル、テスト、特定のエントリーポイントは指定されていません。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 15/100