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

能否提供一个新的助记符never或者noreturn

Open fesily opened this issue 2 years ago • 2 comments

用来标记该函数是抛出异常,永远不返回.

当前内建只支持了函数error

typescript keyword never

function fail(message: string): never {
  throw new Error(message);
}

or c++ attributue noreturn

[[ noreturn ]] void f() {
  throw "error";
}

so, lua maybe like:

---@noreturn
---@never
local function h()end

fesily avatar Aug 20 '22 02:08 fesily

你可以现在 runtime.special 里设置你的函数为 error 。 我目前不是通过分析函数定义来确定是否永远不返回的。

sumneko avatar Aug 20 '22 07:08 sumneko

👌🏻,稍微有一点美中不足的地方,能不能改进一下,runtime.special设定不能识别表中的函数.比如说io.exit这种

fesily avatar Aug 22 '22 07:08 fesily