LuaLS / LuaLS/lua-language-server

Register function environment variables

オープン
#15 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

enhancement feat/LuaCats Annotations priority.normal
主要言語
Lua
スター
4.4k
フォーク
442
PR マージ指標
30日以内にマージされた PR はありません

説明

This extension is able to detect usage of undefined global variables:
![image](https://user-images.githubusercontent.com/1635608/55824214-b3bc4380-5b03-11e9-87a0-7fd50d08a633.png)

However, `setfenv` is used on this function to define the missing variable, but at another point in the code that the parser can't detect. Is it possible to somehow tell the parser to ignore this diagnostic? Something like:
```lua
local block = function(_)
-- env: {block, assert, error}
block()
end
```

Then it would accept those values? I know you can define globals for the project, but this doesn't affect the entire project, only those functions, so it would be cool if you could define it somehow.

Alternatively, could we just disable the diagnostic?
```lua
local block = function(_)
-- disable: undefined-global
block()
end
```

I don't know if the parser supports reading comments like that, let me know if that won't work or if you have better ideas for it.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、parser の未定義グローバル診断を追跡し、プロジェクトレベルのグローバル定義をどのように読み取るかを調べます。次に、issue で提案されている関数ローカル環境のアノテーションと診断を無効化するコメントを評価し、選択した構文が意図した関数スコープの警告だけを抑制または解決することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua
領域
devtools
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。