Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fesily opened this issue Aug 20, 2022 · 2 comments
Closed

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

fesily opened this issue Aug 20, 2022 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@fesily
Copy link
Contributor

fesily commented Aug 20, 2022

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

当前内建只支持了函数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
@sumneko sumneko added the enhancement New feature or request label Aug 20, 2022
@sumneko
Copy link
Collaborator

sumneko commented Aug 20, 2022

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

@fesily
Copy link
Contributor Author

fesily commented Aug 22, 2022

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

@sumneko sumneko added this to the 3.6.0 milestone Sep 19, 2022
sumneko added a commit that referenced this issue Nov 2, 2022
@sumneko sumneko closed this as completed Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants